Skip to content

Commit

Permalink
devlink: don't work with possible NULL pointer in devlink_param_unreg…
Browse files Browse the repository at this point in the history
…ister()

There is a WARN_ON checking the param_item for being NULL when the param
is not inserted in the list. That indicates a driver BUG. Instead of
continuing to work with NULL pointer with its consequences, return.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jiri Pirko authored and David S. Miller committed Jan 27, 2023
1 parent 020dd12 commit bb9bb6b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion net/devlink/leftover.c
Original file line number Diff line number Diff line change
Expand Up @@ -10824,7 +10824,8 @@ static void devlink_param_unregister(struct devlink *devlink,

param_item =
devlink_param_find_by_name(&devlink->param_list, param->name);
WARN_ON(!param_item);
if (WARN_ON(!param_item))
return;
devlink_param_notify(devlink, 0, param_item, DEVLINK_CMD_PARAM_DEL);
list_del(&param_item->list);
kfree(param_item);
Expand Down

0 comments on commit bb9bb6b

Please sign in to comment.