diff options
author | Kangjie Lu <kjlu@umn.edu> | 2019-04-13 13:34:47 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-05-31 16:46:14 +0300 |
commit | 67d812fbe303a3d621dde277a03384797cc95edd (patch) | |
tree | 049b766b531683094a7ef76d78e6d0b6cd1e5fe5 /drivers/slimbus/qcom-ngd-ctrl.c | |
parent | 0cbef22f67ba0c52996b8d05aebee556cf29dce5 (diff) | |
download | linux-67d812fbe303a3d621dde277a03384797cc95edd.tar.xz |
slimbus: fix a potential NULL pointer dereference in of_qcom_slim_ngd_register
[ Upstream commit 06d5d6b7f9948a89543e1160ef852d57892c750d ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/slimbus/qcom-ngd-ctrl.c')
-rw-r--r-- | drivers/slimbus/qcom-ngd-ctrl.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/slimbus/qcom-ngd-ctrl.c b/drivers/slimbus/qcom-ngd-ctrl.c index 14a9d18306cb..f63d1b8a0933 100644 --- a/drivers/slimbus/qcom-ngd-ctrl.c +++ b/drivers/slimbus/qcom-ngd-ctrl.c @@ -1331,6 +1331,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; |