From: Nishka Dasgupta Date: Thu, 15 Aug 2019 06:00:14 +0000 (+0530) Subject: ata: libahci_platform: Add of_node_put() before loop exit X-Git-Tag: v5.4-rc1~54^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d7f76f36a8b4dc8eff0c22819e4a5d55b0dee62a;p=platform%2Fkernel%2Flinux-rpi.git ata: libahci_platform: Add of_node_put() before loop exit Each iteration of for_each_child_of_node puts the previous node, but in the case of a goto from the middle of the loop, there is no put, thus causing a memory leak. Add an of_node_put before three such goto statements. Issue found with Coccinelle. Reviewed-by: Hans de Goede Signed-off-by: Nishka Dasgupta Signed-off-by: Jens Axboe --- diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c index 9e9583a..e742780 100644 --- a/drivers/ata/libahci_platform.c +++ b/drivers/ata/libahci_platform.c @@ -497,6 +497,7 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev, if (of_property_read_u32(child, "reg", &port)) { rc = -EINVAL; + of_node_put(child); goto err_out; } @@ -514,14 +515,18 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev, if (port_dev) { rc = ahci_platform_get_regulator(hpriv, port, &port_dev->dev); - if (rc == -EPROBE_DEFER) + if (rc == -EPROBE_DEFER) { + of_node_put(child); goto err_out; + } } #endif rc = ahci_platform_get_phy(hpriv, port, dev, child); - if (rc) + if (rc) { + of_node_put(child); goto err_out; + } enabled_ports++; }