]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: marvell: prestera: fix a couple NULL vs IS_ERR() checks
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 12 Oct 2022 15:00:59 +0000 (18:00 +0300)
committerJakub Kicinski <kuba@kernel.org>
Thu, 13 Oct 2022 16:33:57 +0000 (09:33 -0700)
The __prestera_nexthop_group_create() function returns NULL on error
and the prestera_nexthop_group_get() returns error pointers.  Fix these
two checks.

Fixes: 9f73a926f0c8 ("net: marvell: prestera: Add router nexthops ABI")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/Y0bWq+7DoKK465z8@kili
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/marvell/prestera/prestera_router_hw.c

index 4f65df0ae5e879d44c99565bb0ed6d8eb3a9a673..aa080dc57ff0050a216c096eb9b585fdf56aaf8f 100644 (file)
@@ -498,8 +498,8 @@ prestera_nexthop_group_get(struct prestera_switch *sw,
                refcount_inc(&nh_grp->refcount);
        } else {
                nh_grp = __prestera_nexthop_group_create(sw, key);
-               if (IS_ERR(nh_grp))
-                       return ERR_CAST(nh_grp);
+               if (!nh_grp)
+                       return ERR_PTR(-ENOMEM);
 
                refcount_set(&nh_grp->refcount, 1);
        }
@@ -651,7 +651,7 @@ prestera_fib_node_create(struct prestera_switch *sw,
        case PRESTERA_FIB_TYPE_UC_NH:
                fib_node->info.nh_grp = prestera_nexthop_group_get(sw,
                                                                   nh_grp_key);
-               if (!fib_node->info.nh_grp)
+               if (IS_ERR(fib_node->info.nh_grp))
                        goto err_nh_grp_get;
 
                grp_id = fib_node->info.nh_grp->grp_id;