devlink: don't work with possible NULL pointer in devlink_param_unregister()
authorJiri Pirko <jiri@nvidia.com>
Thu, 26 Jan 2023 07:58:30 +0000 (08:58 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 27 Jan 2023 12:32:02 +0000 (12:32 +0000)
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>
net/devlink/leftover.c

index b1216b8..fca2b66 100644 (file)
@@ -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);