netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: devlink: Fix missing mutex_unlock() call
       [not found] <202207311503.QBFSGqiL-lkp@intel.com>
@ 2022-08-01 11:59 ` Ammar Faizi
  2022-08-01 14:40   ` Jiri Pirko
  2022-08-01 19:50   ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Ammar Faizi @ 2022-08-01 11:59 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: Ammar Faizi, kernel test robot, Dan Carpenter, Moshe Shemesh,
	Jiri Pirko, Fernanda Ma'rouf, netdev Mailing List,
	GNU/Weeb Mailing List, Linux Kernel Mailing List,
	kbuild Mailing List, kbuild-all Mailing List

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(-)

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,

base-commit: 0a324c3263f1e456f54dd8dc8ce58575aea776bc
-- 
Ammar Faizi


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: devlink: Fix missing mutex_unlock() call
  2022-08-01 11:59 ` [PATCH] net: devlink: Fix missing mutex_unlock() call Ammar Faizi
@ 2022-08-01 14:40   ` Jiri Pirko
  2022-08-01 19:50   ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Jiri Pirko @ 2022-08-01 14:40 UTC (permalink / raw)
  To: Ammar Faizi
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	kernel test robot, Dan Carpenter, Moshe Shemesh, Jiri Pirko,
	Fernanda Ma'rouf, netdev Mailing List, GNU/Weeb Mailing List,
	Linux Kernel Mailing List, kbuild Mailing List,
	kbuild-all Mailing List

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!

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: devlink: Fix missing mutex_unlock() call
  2022-08-01 11:59 ` [PATCH] net: devlink: Fix missing mutex_unlock() call Ammar Faizi
  2022-08-01 14:40   ` Jiri Pirko
@ 2022-08-01 19:50   ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-08-01 19:50 UTC (permalink / raw)
  To: Ammar Faizi
  Cc: davem, edumazet, kuba, pabeni, lkp, dan.carpenter, moshe, jiri,
	fernandafmr12, netdev, gwml, linux-kernel, kbuild, kbuild-all

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-08-01 19:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <202207311503.QBFSGqiL-lkp@intel.com>
2022-08-01 11:59 ` [PATCH] net: devlink: Fix missing mutex_unlock() call Ammar Faizi
2022-08-01 14:40   ` Jiri Pirko
2022-08-01 19:50   ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).