Skip to content

Commit

Permalink
slimbus: fix a potential NULL pointer dereference in of_qcom_slim_ngd…
Browse files Browse the repository at this point in the history
…_register

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

Signed-off-by: Kangjie Lu <[email protected]>
Signed-off-by: Srinivas Kandagatla <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
kengiter authored and gregkh committed Apr 25, 2019
1 parent b281218 commit 06d5d6b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/slimbus/qcom-ngd-ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 06d5d6b

Please sign in to comment.