[PATCH] slimbus: Add a check on the return value of platform_device_add

From: Aditya Pakki
Date: Mon Dec 24 2018 - 11:57:32 EST


In of_qcom_slim_ngd_register, the function platform_device_add() may fail.
The fix returns the error value upstream in case of failure.

Signed-off-by: Aditya Pakki <pakki001@xxxxxxx>
---
drivers/slimbus/qcom-ngd-ctrl.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/slimbus/qcom-ngd-ctrl.c b/drivers/slimbus/qcom-ngd-ctrl.c
index 1382a8df6c75..a2dffb2b4c88 100644
--- a/drivers/slimbus/qcom-ngd-ctrl.c
+++ b/drivers/slimbus/qcom-ngd-ctrl.c
@@ -1329,6 +1329,7 @@ static int of_qcom_slim_ngd_register(struct device *parent,
struct qcom_slim_ngd *ngd;
struct device_node *node;
u32 id;
+ int ret;

data = of_match_node(qcom_slim_ngd_dt_match, parent->of_node)->data;

@@ -1348,7 +1349,10 @@ static int of_qcom_slim_ngd_register(struct device *parent,
ctrl->ngd = ngd;
platform_set_drvdata(ngd->pdev, ctrl);

- platform_device_add(ngd->pdev);
+ ret = platform_device_add(ngd->pdev);
+ if (ret)
+ return ret;
+
ngd->base = ctrl->base + ngd->id * data->offset +
(ngd->id - 1) * data->size;
ctrl->ngd = ngd;
--
2.17.1