]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net: dsa: sja1105: fix memory leak in sja1105_setup_devlink_regions()
authorZhengchao Shao <shaozhengchao@huawei.com>
Mon, 5 Dec 2022 01:21:32 +0000 (09:21 +0800)
committerJakub Kicinski <kuba@kernel.org>
Wed, 7 Dec 2022 04:36:38 +0000 (20:36 -0800)
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>
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>
drivers/net/dsa/sja1105/sja1105_devlink.c

index 10c6fea1227fa698fe8c5a261fb678eb88165f16..bdbbff2a79095c8dbe0b636aba14e9b8b14afffe 100644 (file)
@@ -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);
                }