Skip to content

Commit

Permalink
memory: renesas-rpc-if: fix platform-device leak in error path
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Johan Hovold authored and Krzysztof Kozlowski committed Apr 4, 2022
1 parent 3123109 commit b452dbf
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion drivers/memory/renesas-rpc-if.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
Expand Down

0 comments on commit b452dbf

Please sign in to comment.