Skip to contentSkip to conversation

memory: renesas-rpc-if: fix platform-device leak in error path

PATCH Applied Johan Hovold 3 participants 3 messages Mar 3, 2022 – Apr 4, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 memory: renesas-rpc-if: fix platform-device leak in error path

Make sure to free the flash platform device in the event that registration fails during probe.

Fixes ca7d8b980b67 ("memory: add Renesas RPC-IF driver")
Cc Sergei Shtylyov <[email protected]>
---
 drivers/memory/renesas-rpc-if.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/memory/renesas-rpc-if.c +9 -1
index e4cc64f56019..2e545f473cc6 100644
@@ -651,6 +651,7 @@ static int rpcif_probe(struct platform_device *pdev)
 	struct platform_device *vdev;
 	struct device_node *flash;
 	const char *name;
+	int ret;
 
 	flash = of_get_next_child(pdev->dev.of_node, NULL);
 	if (!flash) {
@@ -674,7 +675,14 @@ static int rpcif_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	vdev->dev.parent = &pdev->dev;
 	platform_set_drvdata(pdev, vdev);
-	return platform_device_add(vdev);
+
+	ret = platform_device_add(vdev);
+	if (ret) {
+		platform_device_put(vdev);
+		return ret;
+	}
+
+	return 0;
 }
 
 static int rpcif_remove(struct platform_device *pdev)
Signature · 1 line
2.34.1
#1 lore raw
Quoted 11 lines · Johan Hovold

Make sure to free the flash platform device in the event that registration fails during probe.

Fixes ca7d8b980b67 ("memory: add Renesas RPC-IF driver")
Cc Sergei Shtylyov <[email protected]>
---
 drivers/memory/renesas-rpc-if.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

It's too late for upcoming cycle, so I will pick it up after the merge window.

Best regards,
Krzysztof

#2 lore raw
In reply to Johan Hovold
Quoted 4 lines · Johan Hovold

Make sure to free the flash platform device in the event that registration fails during probe.

Applied, thanks!

[1/1] memory: renesas-rpc-if: fix platform-device leak in error path

      commit: b452dbf24d7d9a990d70118462925f6ee287d135

Best regards,

Signature · 1 line
Krzysztof Kozlowski <[email protected]>