Skip to content

Commit 30e9672

Browse files
Dan Carpenterkuba-moo
authored andcommitted
net: marvell: prestera: fix a couple NULL vs IS_ERR() checks
The __prestera_nexthop_group_create() function returns NULL on error and the prestera_nexthop_group_get() returns error pointers. Fix these two checks. Fixes: 0a23ae2 ("net: marvell: prestera: Add router nexthops ABI") Signed-off-by: Dan Carpenter <[email protected]> Link: https://lore.kernel.org/r/Y0bWq+7DoKK465z8@kili Signed-off-by: Jakub Kicinski <[email protected]>
1 parent ec7eede commit 30e9672

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/net/ethernet/marvell/prestera/prestera_router_hw.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,8 @@ prestera_nexthop_group_get(struct prestera_switch *sw,
498498
refcount_inc(&nh_grp->refcount);
499499
} else {
500500
nh_grp = __prestera_nexthop_group_create(sw, key);
501-
if (IS_ERR(nh_grp))
502-
return ERR_CAST(nh_grp);
501+
if (!nh_grp)
502+
return ERR_PTR(-ENOMEM);
503503

504504
refcount_set(&nh_grp->refcount, 1);
505505
}
@@ -651,7 +651,7 @@ prestera_fib_node_create(struct prestera_switch *sw,
651651
case PRESTERA_FIB_TYPE_UC_NH:
652652
fib_node->info.nh_grp = prestera_nexthop_group_get(sw,
653653
nh_grp_key);
654-
if (!fib_node->info.nh_grp)
654+
if (IS_ERR(fib_node->info.nh_grp))
655655
goto err_nh_grp_get;
656656

657657
grp_id = fib_node->info.nh_grp->grp_id;

0 commit comments

Comments
 (0)