]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: cpsw: add missing of_node_put() in cpsw_probe_dt()
authorYang Yingliang <yangyingliang@huawei.com>
Fri, 29 Apr 2022 01:53:37 +0000 (09:53 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 12 May 2022 10:25:40 +0000 (12:25 +0200)
commit 95098d5ac2551769807031444e55a0da5d4f0952 upstream.

'tmp_node' need be put before returning from cpsw_probe_dt(),
so add missing of_node_put() in error path.

Fixes: ed3525eda4c4 ("net: ethernet: ti: introduce cpsw switchdev based driver part 1 - dual-emac")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/ti/cpsw_new.c

index 31cefd6ef6806f94f865e281d1f199f4e86bab5d..a1ee205d6a889afeb716f2ba2370fa517491d2fc 100644 (file)
@@ -1255,8 +1255,10 @@ static int cpsw_probe_dt(struct cpsw_common *cpsw)
        data->slave_data = devm_kcalloc(dev, CPSW_SLAVE_PORTS_NUM,
                                        sizeof(struct cpsw_slave_data),
                                        GFP_KERNEL);
-       if (!data->slave_data)
+       if (!data->slave_data) {
+               of_node_put(tmp_node);
                return -ENOMEM;
+       }
 
        /* Populate all the child nodes here...
         */
@@ -1353,6 +1355,7 @@ static int cpsw_probe_dt(struct cpsw_common *cpsw)
 
 err_node_put:
        of_node_put(port_np);
+       of_node_put(tmp_node);
        return ret;
 }