Skip to content

Commit

Permalink
net: dsa: sja1105: fix memory leak in sja1105_setup_devlink_regions()
Browse files Browse the repository at this point in the history
When dsa_devlink_region_create failed in sja1105_setup_devlink_regions(),
priv->regions is not released.

Fixes: bf425b8 ("net: dsa: sja1105: expose static config as devlink region")
Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/20221205012132.2110979-1-shaozhengchao@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Zhengchao Shao authored and Jakub Kicinski committed Dec 7, 2022
1 parent e40febf commit 78a9ea4
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/net/dsa/sja1105/sja1105_devlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 78a9ea4

Please sign in to comment.