2022-07-23 03:37:59

by williamsukatube

[permalink] [raw]
Subject: [PATCH] slimbus: qcom-ngd-ctrl: Add check for platform_driver_register

From: William Dean <[email protected]>

As platform_driver_register() could fail, it should be better
to deal with the return value in order to maintain the code
consisitency.

Fixes: 1830dad34c070 ("slimbus: ngd: register ngd driver only once.")
Reported-by: Hacash Robot <[email protected]>
Signed-off-by: William Dean <[email protected]>
---
drivers/slimbus/qcom-ngd-ctrl.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/slimbus/qcom-ngd-ctrl.c b/drivers/slimbus/qcom-ngd-ctrl.c
index 0aa8408464ad..a31ec00a37ac 100644
--- a/drivers/slimbus/qcom-ngd-ctrl.c
+++ b/drivers/slimbus/qcom-ngd-ctrl.c
@@ -1585,7 +1585,12 @@ static int qcom_slim_ngd_ctrl_probe(struct platform_device *pdev)
return PTR_ERR(pds);
}

- platform_driver_register(&qcom_slim_ngd_driver);
+ ret = platform_driver_register(&qcom_slim_ngd_driver);
+ if (ret) {
+ dev_err(dev, "platform driver register failed: %d\n", ret);
+ return ret;
+ }
+
return of_qcom_slim_ngd_register(dev, ctrl);
}

--
2.25.1