From 30b869e77a1c626190bbbe6b4e5f5382b0102ac3 Mon Sep 17 00:00:00 2001
From: Yong Wu <yong.wu@mediatek.com>
Date: Tue, 14 Sep 2021 19:36:56 +0800
Subject: [PATCH] memory: mtk-smi: Add error handle for smi_probe
Git-commit: 30b869e77a1c626190bbbe6b4e5f5382b0102ac3
Patch-mainline: v5.16-rc1
References: git-fixes
Add error handle while component_add fail.
Signed-off-by: Yong Wu <yong.wu@mediatek.com>
Reviewed-by: Ikjoon Jang <ikjn@chromium.org>
Link: https://lore.kernel.org/r/20210914113703.31466-7-yong.wu@mediatek.com
Fixes: 6ce2c05b2118 ("memory: mtk-smi: Add device-link between smi-larb and smi-common")
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Acked-by: Takashi Iwai <tiwai@suse.de>
---
drivers/memory/mtk-smi.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
--- a/drivers/memory/mtk-smi.c
+++ b/drivers/memory/mtk-smi.c
@@ -320,6 +320,7 @@ static int mtk_smi_larb_probe(struct pla
struct device_node *smi_node;
struct platform_device *smi_pdev;
struct device_link *link;
+ int ret;
larb = devm_kzalloc(dev, sizeof(*larb), GFP_KERNEL);
if (!larb)
@@ -372,7 +373,15 @@ static int mtk_smi_larb_probe(struct pla
pm_runtime_enable(dev);
platform_set_drvdata(pdev, larb);
- return component_add(dev, &mtk_smi_larb_component_ops);
+ ret = component_add(dev, &mtk_smi_larb_component_ops);
+ if (ret)
+ goto err_pm_disable;
+ return 0;
+
+err_pm_disable:
+ pm_runtime_disable(dev);
+ device_link_remove(dev, larb->smi_common_dev);
+ return ret;
}
static int mtk_smi_larb_remove(struct platform_device *pdev)