Skip to content

Commit b452dbf

Browse files
jhovoldkrzk
authored andcommitted
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: ca7d8b9 ("memory: add Renesas RPC-IF driver") Cc: stable@vger.kernel.org # 5.8 Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Signed-off-by: Johan Hovold <johan@kernel.org> Link: https://lore.kernel.org/r/20220303180632.3194-1-johan@kernel.org Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
1 parent 3123109 commit b452dbf

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

drivers/memory/renesas-rpc-if.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,7 @@ static int rpcif_probe(struct platform_device *pdev)
651651
struct platform_device *vdev;
652652
struct device_node *flash;
653653
const char *name;
654+
int ret;
654655

655656
flash = of_get_next_child(pdev->dev.of_node, NULL);
656657
if (!flash) {
@@ -674,7 +675,14 @@ static int rpcif_probe(struct platform_device *pdev)
674675
return -ENOMEM;
675676
vdev->dev.parent = &pdev->dev;
676677
platform_set_drvdata(pdev, vdev);
677-
return platform_device_add(vdev);
678+
679+
ret = platform_device_add(vdev);
680+
if (ret) {
681+
platform_device_put(vdev);
682+
return ret;
683+
}
684+
685+
return 0;
678686
}
679687

680688
static int rpcif_remove(struct platform_device *pdev)

0 commit comments

Comments
 (0)