diff mbox series

net: dsa: sja1105: fix memory leak in sja1105_setup_devlink_regions()

Message ID 20221205012132.2110979-1-shaozhengchao@huawei.com (mailing list archive)
State Accepted
Commit 78a9ea43fc1a7c06a420b132d2d47cbf4344a5df
Delegated to: Netdev Maintainers
Headers show
Series net: dsa: sja1105: fix memory leak in sja1105_setup_devlink_regions() | 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: 0 this patch: 0
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
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: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

shaozhengchao Dec. 5, 2022, 1:21 a.m. UTC
When dsa_devlink_region_create failed in sja1105_setup_devlink_regions(), 
priv->regions is not released.

Fixes: bf425b82059e ("net: dsa: sja1105: expose static config as devlink region")
Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
---
 drivers/net/dsa/sja1105/sja1105_devlink.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Vladimir Oltean Dec. 6, 2022, 5:10 p.m. UTC | #1
On Mon, Dec 05, 2022 at 09:21:32AM +0800, Zhengchao Shao wrote:
> When dsa_devlink_region_create failed in sja1105_setup_devlink_regions(), 
> priv->regions is not released.
> 
> Fixes: bf425b82059e ("net: dsa: sja1105: expose static config as devlink region")
> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
> ---

Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Florian Fainelli Dec. 6, 2022, 10:29 p.m. UTC | #2
On 12/4/22 17:21, Zhengchao Shao wrote:
> When dsa_devlink_region_create failed in sja1105_setup_devlink_regions(),
> priv->regions is not released.
> 
> Fixes: bf425b82059e ("net: dsa: sja1105: expose static config as devlink region")
> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
patchwork-bot+netdevbpf@kernel.org Dec. 7, 2022, 4:40 a.m. UTC | #3
Hello:

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

On Mon, 5 Dec 2022 09:21:32 +0800 you wrote:
> When dsa_devlink_region_create failed in sja1105_setup_devlink_regions(),
> priv->regions is not released.
> 
> Fixes: bf425b82059e ("net: dsa: sja1105: expose static config as devlink region")
> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
> ---
>  drivers/net/dsa/sja1105/sja1105_devlink.c | 2 ++
>  1 file changed, 2 insertions(+)

Here is the summary with links:
  - net: dsa: sja1105: fix memory leak in sja1105_setup_devlink_regions()
    https://git.kernel.org/netdev/net/c/78a9ea43fc1a

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/dsa/sja1105/sja1105_devlink.c b/drivers/net/dsa/sja1105/sja1105_devlink.c
index 10c6fea1227f..bdbbff2a7909 100644
--- a/drivers/net/dsa/sja1105/sja1105_devlink.c
+++ b/drivers/net/dsa/sja1105/sja1105_devlink.c
@@ -95,6 +95,8 @@  static int sja1105_setup_devlink_regions(struct dsa_switch *ds)
 		if (IS_ERR(region)) {
 			while (--i >= 0)
 				dsa_devlink_region_destroy(priv->regions[i]);
+
+			kfree(priv->regions);
 			return PTR_ERR(region);
 		}