diff mbox series

[net-next] devlink: Fix memleak in health diagnose callback

Message ID 1675698976-45993-1-git-send-email-moshe@nvidia.com (mailing list archive)
State Accepted
Commit cb6b2e11a42decea2afc77df73ec7326db1ac25f
Delegated to: Netdev Maintainers
Headers show
Series [net-next] devlink: Fix memleak in health diagnose callback | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
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 fail 1 blamed authors not CCed: jacob.e.keller@intel.com; 3 maintainers not CCed: edumazet@google.com jacob.e.keller@intel.com pabeni@redhat.com
netdev/build_clang success Errors and warnings before: 1 this patch: 1
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, 27 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Moshe Shemesh Feb. 6, 2023, 3:56 p.m. UTC
The callback devlink_nl_cmd_health_reporter_diagnose_doit() miss
devlink_fmsg_free(), which leads to memory leak.

Fix it by adding devlink_fmsg_free().

Fixes: e994a75fb7f9 ("devlink: remove reporter reference counting")
Signed-off-by: Moshe Shemesh <moshe@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
---
 net/devlink/leftover.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

Comments

Simon Horman Feb. 7, 2023, 6:42 a.m. UTC | #1
On Mon, Feb 06, 2023 at 05:56:16PM +0200, Moshe Shemesh wrote:
> The callback devlink_nl_cmd_health_reporter_diagnose_doit() miss
> devlink_fmsg_free(), which leads to memory leak.
> 
> Fix it by adding devlink_fmsg_free().
> 
> Fixes: e994a75fb7f9 ("devlink: remove reporter reference counting")
> Signed-off-by: Moshe Shemesh <moshe@nvidia.com>
> Reviewed-by: Jiri Pirko <jiri@nvidia.com>

Reviewed-by: Simon Horman <simon.horman@corigine.com>
patchwork-bot+netdevbpf@kernel.org Feb. 8, 2023, 4:30 a.m. UTC | #2
Hello:

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

On Mon, 6 Feb 2023 17:56:16 +0200 you wrote:
> The callback devlink_nl_cmd_health_reporter_diagnose_doit() miss
> devlink_fmsg_free(), which leads to memory leak.
> 
> Fix it by adding devlink_fmsg_free().
> 
> Fixes: e994a75fb7f9 ("devlink: remove reporter reference counting")
> Signed-off-by: Moshe Shemesh <moshe@nvidia.com>
> Reviewed-by: Jiri Pirko <jiri@nvidia.com>
> 
> [...]

Here is the summary with links:
  - [net-next] devlink: Fix memleak in health diagnose callback
    https://git.kernel.org/netdev/net-next/c/cb6b2e11a42d

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/devlink/leftover.c b/net/devlink/leftover.c
index 056d9ca14a3d..79bb8320fc3a 100644
--- a/net/devlink/leftover.c
+++ b/net/devlink/leftover.c
@@ -7866,18 +7866,22 @@  static int devlink_nl_cmd_health_reporter_diagnose_doit(struct sk_buff *skb,
 
 	err = devlink_fmsg_obj_nest_start(fmsg);
 	if (err)
-		return err;
+		goto out;
 
 	err = reporter->ops->diagnose(reporter, fmsg, info->extack);
 	if (err)
-		return err;
+		goto out;
 
 	err = devlink_fmsg_obj_nest_end(fmsg);
 	if (err)
-		return err;
+		goto out;
+
+	err = devlink_fmsg_snd(fmsg, info,
+			       DEVLINK_CMD_HEALTH_REPORTER_DIAGNOSE, 0);
 
-	return devlink_fmsg_snd(fmsg, info,
-				DEVLINK_CMD_HEALTH_REPORTER_DIAGNOSE, 0);
+out:
+	devlink_fmsg_free(fmsg);
+	return err;
 }
 
 static int