linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] slimbus: ngd: Fix to avoid potential NULL pointer dereference
@ 2019-03-19  1:25 Aditya Pakki
  2019-03-20 14:47 ` Srinivas Kandagatla
  0 siblings, 1 reply; 2+ messages in thread
From: Aditya Pakki @ 2019-03-19  1:25 UTC (permalink / raw)
  To: pakki001
  Cc: kjlu, Andy Gross, David Brown, Srinivas Kandagatla,
	linux-arm-msm, alsa-devel, linux-kernel

In of_qcom_slim_ngd_register, of_match_node may fail and return a NULL
pointer. This patch avoids such a scenario leading to NULL pointer
dereference.

Fixes: 458a445deb9c ("slimbus: ngd: Fix build error on x86")
Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
 drivers/slimbus/qcom-ngd-ctrl.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/slimbus/qcom-ngd-ctrl.c b/drivers/slimbus/qcom-ngd-ctrl.c
index 71f094c9ec68..9cc7256028c9 100644
--- a/drivers/slimbus/qcom-ngd-ctrl.c
+++ b/drivers/slimbus/qcom-ngd-ctrl.c
@@ -1332,6 +1332,8 @@ static int of_qcom_slim_ngd_register(struct device *parent,
 	u32 id;
 
 	match = of_match_node(qcom_slim_ngd_dt_match, parent->of_node);
+	if (!match)
+		return -ENXIO;
 	data = match->data;
 	for_each_available_child_of_node(parent->of_node, node) {
 		if (of_property_read_u32(node, "reg", &id))
-- 
2.17.1


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

* Re: [PATCH] slimbus: ngd: Fix to avoid potential NULL pointer dereference
  2019-03-19  1:25 [PATCH] slimbus: ngd: Fix to avoid potential NULL pointer dereference Aditya Pakki
@ 2019-03-20 14:47 ` Srinivas Kandagatla
  0 siblings, 0 replies; 2+ messages in thread
From: Srinivas Kandagatla @ 2019-03-20 14:47 UTC (permalink / raw)
  To: Aditya Pakki
  Cc: kjlu, Andy Gross, David Brown, linux-arm-msm, alsa-devel, linux-kernel



On 19/03/2019 01:25, Aditya Pakki wrote:
> In of_qcom_slim_ngd_register, of_match_node may fail and return a NULL
> pointer. This patch avoids such a scenario leading to NULL pointer
> dereference.
> 
> Fixes: 458a445deb9c ("slimbus: ngd: Fix build error on x86")
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> ---
>   drivers/slimbus/qcom-ngd-ctrl.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/slimbus/qcom-ngd-ctrl.c b/drivers/slimbus/qcom-ngd-ctrl.c
> index 71f094c9ec68..9cc7256028c9 100644
> --- a/drivers/slimbus/qcom-ngd-ctrl.c
> +++ b/drivers/slimbus/qcom-ngd-ctrl.c
> @@ -1332,6 +1332,8 @@ static int of_qcom_slim_ngd_register(struct device *parent,
>   	u32 id;
>   
>   	match = of_match_node(qcom_slim_ngd_dt_match, parent->of_node);
> +	if (!match)
> +		return -ENXIO;

We would not even enter this path without matching compatible, so I 
think a check here is not really necessary.

thanks,
srini

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

end of thread, other threads:[~2019-03-20 14:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-19  1:25 [PATCH] slimbus: ngd: Fix to avoid potential NULL pointer dereference Aditya Pakki
2019-03-20 14:47 ` 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).