[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220914031953.94061-1-linyujun809@huawei.com>
Date: Wed, 14 Sep 2022 11:19:53 +0800
From: Lin Yujun <linyujun809@...wei.com>
To: <agross@...nel.org>, <bjorn.andersson@...aro.org>,
<konrad.dybcio@...ainline.org>, <srinivas.kandagatla@...aro.org>,
<gregkh@...uxfoundation.org>, <vkoul@...nel.org>
CC: <linux-arm-msm@...r.kernel.org>, <alsa-devel@...a-project.org>,
<linux-kernel@...r.kernel.org>
Subject: [PATCH -next] slimbus: qcom-ngd: Add error handling in of_qcom_slim_ngd_register
No error handling is performed when platform_device_add()
return fails. Refer to the error handling of driver_set_override(),
add error handling for platform_device_add().
Fixes: 917809e2280b ("slimbus: ngd: Add qcom SLIMBus NGD driver")
Signed-off-by: Lin Yujun <linyujun809@...wei.com>
---
drivers/slimbus/qcom-ngd-ctrl.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/slimbus/qcom-ngd-ctrl.c b/drivers/slimbus/qcom-ngd-ctrl.c
index 0aa8408464ad..fb591990ddad 100644
--- a/drivers/slimbus/qcom-ngd-ctrl.c
+++ b/drivers/slimbus/qcom-ngd-ctrl.c
@@ -1470,7 +1470,13 @@ static int of_qcom_slim_ngd_register(struct device *parent,
ngd->pdev->dev.of_node = node;
ctrl->ngd = ngd;
- platform_device_add(ngd->pdev);
+ ret = platform_device_add(ngd->pdev);
+ if (ret) {
+ platform_device_put(ngd->pdev);
+ kfree(ngd);
+ of_node_put(node);
+ return ret;
+ }
ngd->base = ctrl->base + ngd->id * data->offset +
(ngd->id - 1) * data->size;
--
2.17.1
Powered by blists - more mailing lists