summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKangjie Lu <kjlu@umn.edu>2019-04-13 11:34:47 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-04-25 22:23:06 +0200
commit06d5d6b7f9948a89543e1160ef852d57892c750d (patch)
tree5cc169094ac96f69f1cdff58f5046b5b0a18734b
parentb281218ad4311a0342a40cb02fb17a363df08b48 (diff)
downloadlinux-06d5d6b7f9948a89543e1160ef852d57892c750d.tar.gz
linux-06d5d6b7f9948a89543e1160ef852d57892c750d.tar.bz2
linux-06d5d6b7f9948a89543e1160ef852d57892c750d.zip
slimbus: fix a potential NULL pointer dereference in of_qcom_slim_ngd_register
In case platform_device_alloc fails, the fix returns an error code to avoid the NULL pointer dereference. Signed-off-by: Kangjie Lu <kjlu@umn.edu> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/slimbus/qcom-ngd-ctrl.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/slimbus/qcom-ngd-ctrl.c b/drivers/slimbus/qcom-ngd-ctrl.c
index 71f094c9ec68..f3585777324c 100644
--- a/drivers/slimbus/qcom-ngd-ctrl.c
+++ b/drivers/slimbus/qcom-ngd-ctrl.c
@@ -1342,6 +1342,10 @@ static int of_qcom_slim_ngd_register(struct device *parent,
return -ENOMEM;
ngd->pdev = platform_device_alloc(QCOM_SLIM_NGD_DRV_NAME, id);
+ if (!ngd->pdev) {
+ kfree(ngd);
+ return -ENOMEM;
+ }
ngd->id = id;
ngd->pdev->dev.parent = parent;
ngd->pdev->driver_override = QCOM_SLIM_NGD_DRV_NAME;