diff mbox series

net: devlink: Fix missing mutex_unlock() call

Message ID 20220801115742.1309329-1-ammar.faizi@intel.com (mailing list archive)
State Accepted
Commit 80ef928643c1558a0474389fcd680a5ccd6c86e6
Delegated to: Netdev Maintainers
Headers show
Series net: devlink: Fix missing mutex_unlock() call | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 2 this patch: 2
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 5 this patch: 5
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 2 this patch: 2
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 12 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Ammar Faizi Aug. 1, 2022, 11:59 a.m. UTC
From: Ammar Faizi <ammarfaizi2@gnuweeb.org>

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: 2dec18ad826f52658f7781ee995d236cc449b678 ("net: devlink: remove region snapshots list dependency on devlink->lock")
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
---
 net/core/devlink.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)


base-commit: 0a324c3263f1e456f54dd8dc8ce58575aea776bc

Comments

Jiri Pirko Aug. 1, 2022, 2:40 p.m. UTC | #1
Mon, Aug 01, 2022 at 01:59:56PM CEST, ammarfaizi2@gnuweeb.org wrote:
>From: Ammar Faizi <ammarfaizi2@gnuweeb.org>
>
>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: 2dec18ad826f52658f7781ee995d236cc449b678 ("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>

Thanks for the fix!
patchwork-bot+netdevbpf@kernel.org Aug. 1, 2022, 7:50 p.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Mon,  1 Aug 2022 18:59:56 +0700 you wrote:
> From: Ammar Faizi <ammarfaizi2@gnuweeb.org>
> 
> 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'.
> 
> [...]

Here is the summary with links:
  - net: devlink: Fix missing mutex_unlock() call
    https://git.kernel.org/netdev/net-next/c/80ef928643c1

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/core/devlink.c b/net/core/devlink.c
index 889e7e3d3e8a..5da5c7cca98a 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -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,