phy: tegra: xusb-tegra210: Fix reference leaks in tegra210_xusb_padctl_probe
Subsystems (4)
PATCH 1/1 phy: tegra: xusb-tegra210: Fix reference leaks in tegra210_xusb_padctl_probe
Add missing of_node_put() and put_device() calls to release references.
The function calls of_parse_phandle() and of_find_device_by_node() but fails to release the references.
Both functions' documentation mentions that
the returned references must be dropped after use.
Found through static analysis by reviewing the documentation and cross-checking their usage patterns.
--- drivers/phy/tegra/xusb-tegra210.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/phy/tegra/xusb-tegra210.c +6 -1
@@ -3164,18 +3164,23 @@ tegra210_xusb_padctl_probe(struct device *dev, } pdev =of_find_device_by_node (np); +of_node_put (np);if (!pdev) {dev_warn (dev,"PMC device is not available\n" ); goto out; } -if (!platform_get_drvdata (pdev)) +if (!platform_get_drvdata (pdev)) { +put_device (&pdev->dev);return ERR_PTR (-EPROBE_DEFER ); + } padctl->regmap =dev_get_regmap (&pdev->dev,"usb_sleepwalk" );if (!padctl->regmap)dev_info (dev,"failed to find PMC regmap\n" ); +put_device (&pdev->dev); + out:return &padctl->base; }
Signature · 1 line
2.35.1
Quoted 1 line
Add missing
of_node_put()andput_device()calls to release references.
How do you think about to increase the application of scope-based resource management?
…
Quoted 1 line
Found through static analysis by …
Which concrete software tools would be involved for this purpose?
Regards,
Markus
Quoted 1 line
Add missing
of_node_put()andput_device()calls to release references.
See also the commit bca065733afd1e3a89a02f05ffe14e966cd5f78e ("phy: tegra: xusb:
fix device and OF node leak at probe") by Johan Hovold.
Regards,
Markus