提交 e51b81b2 编写于 作者: J Johan Hovold 提交者: Zheng Zengkai

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

stable inclusion
from stable-v5.10.112
commit c089ffc846c85f200db34ad208338f4f81a6d82d
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5HL0X

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=c089ffc846c85f200db34ad208338f4f81a6d82d

--------------------------------

commit b452dbf2 upstream.

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

Fixes: ca7d8b98 ("memory: add Renesas RPC-IF driver")
Cc: stable@vger.kernel.org      # 5.8
Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: NJohan Hovold <johan@kernel.org>
Link: https://lore.kernel.org/r/20220303180632.3194-1-johan@kernel.orgSigned-off-by: NKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 6d51bada
...@@ -592,6 +592,7 @@ static int rpcif_probe(struct platform_device *pdev) ...@@ -592,6 +592,7 @@ static int rpcif_probe(struct platform_device *pdev)
struct platform_device *vdev; struct platform_device *vdev;
struct device_node *flash; struct device_node *flash;
const char *name; const char *name;
int ret;
flash = of_get_next_child(pdev->dev.of_node, NULL); flash = of_get_next_child(pdev->dev.of_node, NULL);
if (!flash) { if (!flash) {
...@@ -615,7 +616,14 @@ static int rpcif_probe(struct platform_device *pdev) ...@@ -615,7 +616,14 @@ static int rpcif_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
vdev->dev.parent = &pdev->dev; vdev->dev.parent = &pdev->dev;
platform_set_drvdata(pdev, vdev); 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) static int rpcif_remove(struct platform_device *pdev)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册