xfrm: fix 'passing zero to ERR_PTR()' warning
authorYueHaibing <yuehaibing@huawei.com>
Wed, 25 Jul 2018 08:54:33 +0000 (16:54 +0800)
committerSteffen Klassert <steffen.klassert@secunet.com>
Thu, 26 Jul 2018 05:13:44 +0000 (07:13 +0200)
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>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
net/xfrm/xfrm_policy.c

index 2f70fe68b9b0fa81ae2ec9579d1c9c5d28a79729..69f06f879091ea9b10a6958adeb51ea40be9d008 100644 (file)
@@ -1752,7 +1752,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);
        }