aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhengchao Shao <[email protected]>2022-12-05 09:21:32 +0800
committerJakub Kicinski <[email protected]>2022-12-06 20:36:38 -0800
commit78a9ea43fc1a7c06a420b132d2d47cbf4344a5df (patch)
tree6cb63689fa164680dd7e4227acaa9750aadae253
parente40febfb9c99bc30a0dcb60e39b00beb656fdb0f (diff)
net: dsa: sja1105: fix memory leak in sja1105_setup_devlink_regions()
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 <[email protected]> Reviewed-by: Vladimir Oltean <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
-rw-r--r--drivers/net/dsa/sja1105/sja1105_devlink.c2
1 files changed, 2 insertions, 0 deletions
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);
}