Skip to contentSkip to conversation

slimbus: fix a NULL pointer dereference in of_qcom_slim_ngd_register

PATCH Applied Kangjie Lu 2 participants 2 messages Mar 15, 2019 – Mar 20, 2019

Subsystems (2)
lore
Share & tools
lore

Kangjie Lu

author
#0 lore raw

PATCH 1/1 slimbus: fix a 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.

---
 drivers/slimbus/qcom-ngd-ctrl.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/slimbus/qcom-ngd-ctrl.c +4 -0
index 71f094c9ec68..f3585777324c 100644
@@ -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;
Signature · 1 line
2.17.1
#1 lore raw
Quoted 8 lines · Kangjie Lu

In case platform_device_alloc fails, the fix returns an error code to avoid the NULL pointer dereference.

---
  drivers/slimbus/qcom-ngd-ctrl.c | 4 ++++
  1 file changed, 4 insertions(+)

Thanks Applied.

--srini