Skip to content

Commit e62d393

Browse files
nathanchanceklassert
authored andcommitted
xfrm: policy: Restore dir assignments in xfrm_hash_rebuild()
Clang warns (or errors with CONFIG_WERROR): net/xfrm/xfrm_policy.c:1286:8: error: variable 'dir' is uninitialized when used here [-Werror,-Wuninitialized] 1286 | if ((dir & XFRM_POLICY_MASK) == XFRM_POLICY_OUT) { | ^~~ net/xfrm/xfrm_policy.c:1257:9: note: initialize the variable 'dir' to silence this warning 1257 | int dir; | ^ | = 0 1 error generated. A recent refactoring removed some assignments to dir because xfrm_policy_is_dead_or_sk() has a dir assignment in it. However, dir is used elsewhere in xfrm_hash_rebuild(), including within loops where it needs to be reloaded for each policy. Restore the assignments before the first use of dir to fix the warning and ensure dir is properly initialized throughout the function. Fixes: 08c2182 ("xfrm: policy: use recently added helper in more places") Acked-by: Florian Westphal <[email protected]> Signed-off-by: Nathan Chancellor <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
1 parent 6a13f5a commit e62d393

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

net/xfrm/xfrm_policy.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,7 @@ static void xfrm_hash_rebuild(struct work_struct *work)
12831283
if (xfrm_policy_is_dead_or_sk(policy))
12841284
continue;
12851285

1286+
dir = xfrm_policy_id2dir(policy->index);
12861287
if ((dir & XFRM_POLICY_MASK) == XFRM_POLICY_OUT) {
12871288
if (policy->family == AF_INET) {
12881289
dbits = rbits4;
@@ -1337,6 +1338,7 @@ static void xfrm_hash_rebuild(struct work_struct *work)
13371338
hlist_del_rcu(&policy->bydst);
13381339

13391340
newpos = NULL;
1341+
dir = xfrm_policy_id2dir(policy->index);
13401342
chain = policy_hash_bysel(net, &policy->selector,
13411343
policy->family, dir);
13421344

0 commit comments

Comments
 (0)