* [PATCH] firmware: arm_scmi: Fix to check return value of of_match_device
@ 2019-03-18 23:04 ` Aditya Pakki
0 siblings, 0 replies; 4+ messages in thread
From: Aditya Pakki @ 2019-03-18 23:04 UTC (permalink / raw)
To: pakki001; +Cc: kjlu, Sudeep Holla, linux-arm-kernel, linux-kernel
of_match_device can return NULL if no matching device is found. This patch
checks and returns -ENODEV in such a scenario.
Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
drivers/firmware/arm_scmi/driver.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index 8f952f2f1a29..0e0330b44b7b 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -799,6 +799,8 @@ static int scmi_probe(struct platform_device *pdev)
}
desc = of_match_device(scmi_of_match, dev)->data;
+ if (!desc)
+ return -ENODEV;
info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
if (!info)
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] firmware: arm_scmi: Fix to check return value of of_match_device
@ 2019-03-18 23:04 ` Aditya Pakki
0 siblings, 0 replies; 4+ messages in thread
From: Aditya Pakki @ 2019-03-18 23:04 UTC (permalink / raw)
To: pakki001; +Cc: kjlu, linux-kernel, linux-arm-kernel, Sudeep Holla
of_match_device can return NULL if no matching device is found. This patch
checks and returns -ENODEV in such a scenario.
Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
drivers/firmware/arm_scmi/driver.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index 8f952f2f1a29..0e0330b44b7b 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -799,6 +799,8 @@ static int scmi_probe(struct platform_device *pdev)
}
desc = of_match_device(scmi_of_match, dev)->data;
+ if (!desc)
+ return -ENODEV;
info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
if (!info)
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] firmware: arm_scmi: Fix to check return value of of_match_device
2019-03-18 23:04 ` Aditya Pakki
@ 2019-03-22 16:44 ` Steven Price
-1 siblings, 0 replies; 4+ messages in thread
From: Steven Price @ 2019-03-22 16:44 UTC (permalink / raw)
To: Aditya Pakki; +Cc: kjlu, linux-kernel, linux-arm-kernel, Sudeep Holla
On 18/03/2019 23:04, Aditya Pakki wrote:
> of_match_device can return NULL if no matching device is found. This patch
> checks and returns -ENODEV in such a scenario.
>
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> ---
> drivers/firmware/arm_scmi/driver.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
> index 8f952f2f1a29..0e0330b44b7b 100644
> --- a/drivers/firmware/arm_scmi/driver.c
> +++ b/drivers/firmware/arm_scmi/driver.c
> @@ -799,6 +799,8 @@ static int scmi_probe(struct platform_device *pdev)
> }
>
> desc = of_match_device(scmi_of_match, dev)->data;
> + if (!desc)
> + return -ENODEV;
If of_match_device() returns NULL, we've already dereferenced it due to
the "->data" access.
This would be better changed to be a call to of_device_get_match_data()
which handles the NULL return gracefully.
Steve
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] firmware: arm_scmi: Fix to check return value of of_match_device
@ 2019-03-22 16:44 ` Steven Price
0 siblings, 0 replies; 4+ messages in thread
From: Steven Price @ 2019-03-22 16:44 UTC (permalink / raw)
To: Aditya Pakki; +Cc: kjlu, linux-kernel, linux-arm-kernel, Sudeep Holla
On 18/03/2019 23:04, Aditya Pakki wrote:
> of_match_device can return NULL if no matching device is found. This patch
> checks and returns -ENODEV in such a scenario.
>
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> ---
> drivers/firmware/arm_scmi/driver.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
> index 8f952f2f1a29..0e0330b44b7b 100644
> --- a/drivers/firmware/arm_scmi/driver.c
> +++ b/drivers/firmware/arm_scmi/driver.c
> @@ -799,6 +799,8 @@ static int scmi_probe(struct platform_device *pdev)
> }
>
> desc = of_match_device(scmi_of_match, dev)->data;
> + if (!desc)
> + return -ENODEV;
If of_match_device() returns NULL, we've already dereferenced it due to
the "->data" access.
This would be better changed to be a call to of_device_get_match_data()
which handles the NULL return gracefully.
Steve
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-03-22 16:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-18 23:04 [PATCH] firmware: arm_scmi: Fix to check return value of of_match_device Aditya Pakki
2019-03-18 23:04 ` Aditya Pakki
2019-03-22 16:44 ` Steven Price
2019-03-22 16:44 ` Steven Price
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.