Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 330e832a authored by Florian Westphal's avatar Florian Westphal Committed by Steffen Klassert
Browse files

xfrm: unbreak xfrm_sk_policy_lookup



if we succeed grabbing the refcount, then
  if (err && !xfrm_pol_hold_rcu)

will evaluate to false so this hits last else branch which then
sets policy to ERR_PTR(0).

Fixes: ae33786f ("xfrm: policy: only use rcu in xfrm_sk_policy_lookup")
Reported-by: default avatarNicolas Dichtel <nicolas.dichtel@6wind.com>
Tested-by: default avatarNicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
parent 7f92083e
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -1268,12 +1268,14 @@ static struct xfrm_policy *xfrm_sk_policy_lookup(const struct sock *sk, int dir,
			err = security_xfrm_policy_lookup(pol->security,
						      fl->flowi_secid,
						      policy_to_flow_dir(dir));
			if (!err && !xfrm_pol_hold_rcu(pol))
			if (!err) {
				if (!xfrm_pol_hold_rcu(pol))
					goto again;
			else if (err == -ESRCH)
			} else if (err == -ESRCH) {
				pol = NULL;
			else
			} else {
				pol = ERR_PTR(err);
			}
		} else
			pol = NULL;
	}