]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net: devlink: Fix missing mutex_unlock() call
authorAmmar Faizi <ammarfaizi2@gnuweeb.org>
Mon, 1 Aug 2022 11:59:56 +0000 (18:59 +0700)
committerJakub Kicinski <kuba@kernel.org>
Mon, 1 Aug 2022 19:47:10 +0000 (12:47 -0700)
Commit 2dec18ad826f forgets to call mutex_unlock() before the function
returns in the error path:

   New smatch warnings:
   net/core/devlink.c:6392 devlink_nl_cmd_region_new() warn: inconsistent \
   returns '&region->snapshot_lock'.

Make sure we call mutex_unlock() in this error path.

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: 2dec18ad826f ("net: devlink: remove region snapshots list dependency on devlink->lock")
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Link: https://lore.kernel.org/r/20220801115742.1309329-1-ammar.faizi@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/devlink.c

index 889e7e3d3e8af1a8fc97f7abf24b76dbf5c1786f..5da5c7cca98a38632ac3067900689f96c0d8a1e5 100644 (file)
@@ -6315,8 +6315,10 @@ devlink_nl_cmd_region_new(struct sk_buff *skb, struct genl_info *info)
 
                snapshot = devlink_region_snapshot_get_by_id(region,
                                                             snapshot_id);
-               if (WARN_ON(!snapshot))
-                       return -EINVAL;
+               if (WARN_ON(!snapshot)) {
+                       err = -EINVAL;
+                       goto unlock;
+               }
 
                msg = devlink_nl_region_notify_build(region, snapshot,
                                                     DEVLINK_CMD_REGION_NEW,