Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: f5e2bb4f5b22 ("xfrm: policy: xfrm_get_tos cannot fail")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>

authored by

Xin Long and committed by
Steffen Klassert
143a4454 510c321b

+5 -2
+5 -2
net/xfrm/xfrm_policy.c
··· 1458 1458 static int xfrm_get_tos(const struct flowi *fl, int family) 1459 1459 { 1460 1460 const struct xfrm_policy_afinfo *afinfo; 1461 - int tos = 0; 1461 + int tos; 1462 1462 1463 1463 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); 1465 1468 1466 1469 rcu_read_unlock(); 1467 1470