linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] slimbus: fix a NULL pointer dereference in of_qcom_slim_ngd_register
@ 2019-03-15  6:20 Kangjie Lu
  2019-03-20 14:52 ` Srinivas Kandagatla
  0 siblings, 1 reply; 3+ messages in thread
From: Kangjie Lu @ 2019-03-15  6:20 UTC (permalink / raw)
  To: kjlu
  Cc: pakki001, Andy Gross, David Brown, Srinivas Kandagatla,
	linux-arm-msm, alsa-devel, linux-kernel

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>
---
 drivers/slimbus/qcom-ngd-ctrl.c | 4 ++++
 1 file changed, 4 insertions(+)

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;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] slimbus: fix a NULL pointer dereference in of_qcom_slim_ngd_register
  2019-03-15  6:20 [PATCH] slimbus: fix a NULL pointer dereference in of_qcom_slim_ngd_register Kangjie Lu
@ 2019-03-20 14:52 ` Srinivas Kandagatla
  0 siblings, 0 replies; 3+ messages in thread
From: Srinivas Kandagatla @ 2019-03-20 14:52 UTC (permalink / raw)
  To: Kangjie Lu
  Cc: pakki001, Andy Gross, David Brown, linux-arm-msm, alsa-devel,
	linux-kernel



On 15/03/2019 06:20, Kangjie Lu wrote:
> 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>
> ---
>   drivers/slimbus/qcom-ngd-ctrl.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
Thanks Applied.

--srini

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] slimbus: fix a NULL pointer dereference in of_qcom_slim_ngd_register
@ 2019-04-13 10:34 Srinivas Kandagatla
  0 siblings, 0 replies; 3+ messages in thread
From: Srinivas Kandagatla @ 2019-04-13 10:34 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, srinivas.kandagatla

From: Kangjie Lu <kjlu@umn.edu>

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>
---
 drivers/slimbus/qcom-ngd-ctrl.c | 4 ++++
 1 file changed, 4 insertions(+)

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;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-04-13 10:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-15  6:20 [PATCH] slimbus: fix a NULL pointer dereference in of_qcom_slim_ngd_register Kangjie Lu
2019-03-20 14:52 ` Srinivas Kandagatla
2019-04-13 10:34 Srinivas Kandagatla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).