All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] xfrm: do not call rcu_read_unlock when afinfo is NULL in xfrm_get_tos
@ 2018-02-17  7:16 Xin Long
  2018-02-20  6:38 ` Steffen Klassert
  0 siblings, 1 reply; 2+ messages in thread
From: Xin Long @ 2018-02-17  7:16 UTC (permalink / raw)
  To: network dev; +Cc: davem, Steffen Klassert, Florian Westphal

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>
---
 net/xfrm/xfrm_policy.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 7a23078..dd4041f 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1458,10 +1458,13 @@ xfrm_tmpl_resolve(struct xfrm_policy **pols, int npols, const struct flowi *fl,
 static int xfrm_get_tos(const struct flowi *fl, int family)
 {
 	const struct xfrm_policy_afinfo *afinfo;
-	int tos = 0;
+	int tos;
 
 	afinfo = xfrm_policy_get_afinfo(family);
-	tos = afinfo ? afinfo->get_tos(fl) : 0;
+	if (!afinfo)
+		return 0;
+
+	tos = afinfo->get_tos(fl);
 
 	rcu_read_unlock();
 
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] xfrm: do not call rcu_read_unlock when afinfo is NULL in xfrm_get_tos
  2018-02-17  7:16 [PATCH net] xfrm: do not call rcu_read_unlock when afinfo is NULL in xfrm_get_tos Xin Long
@ 2018-02-20  6:38 ` Steffen Klassert
  0 siblings, 0 replies; 2+ messages in thread
From: Steffen Klassert @ 2018-02-20  6:38 UTC (permalink / raw)
  To: Xin Long; +Cc: network dev, davem, Florian Westphal

On Sat, Feb 17, 2018 at 03:16:22PM +0800, Xin Long wrote:
> 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>

Applied, thanks Xin!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-02-20  6:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-17  7:16 [PATCH net] xfrm: do not call rcu_read_unlock when afinfo is NULL in xfrm_get_tos Xin Long
2018-02-20  6:38 ` Steffen Klassert

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.