Commit 30e9672a authored by Dan Carpenter's avatar Dan Carpenter Committed by Jakub Kicinski

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: 0a23ae23 ("net: marvell: prestera: Add router nexthops ABI")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/Y0bWq+7DoKK465z8@kiliSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent ec7eede3
...@@ -498,8 +498,8 @@ prestera_nexthop_group_get(struct prestera_switch *sw, ...@@ -498,8 +498,8 @@ prestera_nexthop_group_get(struct prestera_switch *sw,
refcount_inc(&nh_grp->refcount); refcount_inc(&nh_grp->refcount);
} else { } else {
nh_grp = __prestera_nexthop_group_create(sw, key); nh_grp = __prestera_nexthop_group_create(sw, key);
if (IS_ERR(nh_grp)) if (!nh_grp)
return ERR_CAST(nh_grp); return ERR_PTR(-ENOMEM);
refcount_set(&nh_grp->refcount, 1); refcount_set(&nh_grp->refcount, 1);
} }
...@@ -651,7 +651,7 @@ prestera_fib_node_create(struct prestera_switch *sw, ...@@ -651,7 +651,7 @@ prestera_fib_node_create(struct prestera_switch *sw,
case PRESTERA_FIB_TYPE_UC_NH: case PRESTERA_FIB_TYPE_UC_NH:
fib_node->info.nh_grp = prestera_nexthop_group_get(sw, fib_node->info.nh_grp = prestera_nexthop_group_get(sw,
nh_grp_key); nh_grp_key);
if (!fib_node->info.nh_grp) if (IS_ERR(fib_node->info.nh_grp))
goto err_nh_grp_get; goto err_nh_grp_get;
grp_id = fib_node->info.nh_grp->grp_id; grp_id = fib_node->info.nh_grp->grp_id;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment