Skip to content

Commit 143a445

Browse files
lxinklassert
authored andcommitted
xfrm: do not call rcu_read_unlock when afinfo is NULL in xfrm_get_tos
When xfrm_policy_get_afinfo returns NULL, it will not hold rcu read lock. In this case, rcu_read_unlock should not be called in xfrm_get_tos, just like other places where it's calling xfrm_policy_get_afinfo. Fixes: f5e2bb4 ("xfrm: policy: xfrm_get_tos cannot fail") Signed-off-by: Xin Long <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
1 parent 510c321 commit 143a445

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

net/xfrm/xfrm_policy.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,10 +1458,13 @@ xfrm_tmpl_resolve(struct xfrm_policy **pols, int npols, const struct flowi *fl,
14581458
static int xfrm_get_tos(const struct flowi *fl, int family)
14591459
{
14601460
const struct xfrm_policy_afinfo *afinfo;
1461-
int tos = 0;
1461+
int tos;
14621462

14631463
afinfo = xfrm_policy_get_afinfo(family);
1464-
tos = afinfo ? afinfo->get_tos(fl) : 0;
1464+
if (!afinfo)
1465+
return 0;
1466+
1467+
tos = afinfo->get_tos(fl);
14651468

14661469
rcu_read_unlock();
14671470

0 commit comments

Comments
 (0)