]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
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 b1216b8f0acca37c57b8dd0104a7bed4f2055746..fca2b666136299cfc8f3636c86a91224d41daa0a 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);