All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH ipsec-next] xfrm: fix 'passing zero to ERR_PTR()' warning
@ 2018-07-25  8:54 YueHaibing
  2018-07-27  5:37 ` Steffen Klassert
  0 siblings, 1 reply; 2+ messages in thread
From: YueHaibing @ 2018-07-25  8:54 UTC (permalink / raw)
  To: davem, steffen.klassert, herbert; +Cc: linux-kernel, netdev, YueHaibing

Fix a static code checker warning:

  net/xfrm/xfrm_policy.c:1836 xfrm_resolve_and_create_bundle() warn: passing zero to 'ERR_PTR'

xfrm_tmpl_resolve return 0 just means no xdst found, return NULL
instead of passing zero to ERR_PTR.

Fixes: d809ec895505 ("xfrm: do not assume that template resolving always returns xfrms")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 net/xfrm/xfrm_policy.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 5f48251..4adbeb2 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1831,7 +1831,10 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
 	/* Try to instantiate a bundle */
 	err = xfrm_tmpl_resolve(pols, num_pols, fl, xfrm, family);
 	if (err <= 0) {
-		if (err != 0 && err != -EAGAIN)
+		if (err == 0)
+			return NULL;
+
+		if (err != -EAGAIN)
 			XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTPOLERROR);
 		return ERR_PTR(err);
 	}
-- 
2.7.0



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

* Re: [PATCH ipsec-next] xfrm: fix 'passing zero to ERR_PTR()' warning
  2018-07-25  8:54 [PATCH ipsec-next] xfrm: fix 'passing zero to ERR_PTR()' warning YueHaibing
@ 2018-07-27  5:37 ` Steffen Klassert
  0 siblings, 0 replies; 2+ messages in thread
From: Steffen Klassert @ 2018-07-27  5:37 UTC (permalink / raw)
  To: YueHaibing; +Cc: davem, herbert, linux-kernel, netdev

On Wed, Jul 25, 2018 at 04:54:33PM +0800, YueHaibing wrote:
> Fix a static code checker warning:
> 
>   net/xfrm/xfrm_policy.c:1836 xfrm_resolve_and_create_bundle() warn: passing zero to 'ERR_PTR'
> 
> xfrm_tmpl_resolve return 0 just means no xdst found, return NULL
> instead of passing zero to ERR_PTR.
> 
> Fixes: d809ec895505 ("xfrm: do not assume that template resolving always returns xfrms")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>

Applied, thanks a lot!

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

end of thread, other threads:[~2018-07-27  5:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-25  8:54 [PATCH ipsec-next] xfrm: fix 'passing zero to ERR_PTR()' warning YueHaibing
2018-07-27  5:37 ` 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.