From: Steven Price <steven.price@arm.com>
To: Aditya Pakki <pakki001@umn.edu>
Cc: kjlu@umn.edu, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Sudeep Holla <sudeep.holla@arm.com>
Subject: Re: [PATCH] firmware: arm_scmi: Fix to check return value of of_match_device
Date: Fri, 22 Mar 2019 16:44:49 +0000 [thread overview]
Message-ID: <6053ea18-f092-bb4a-fe0a-a40eda1abfdd@arm.com> (raw)
In-Reply-To: <20190318230430.8273-1-pakki001@umn.edu>
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
prev parent reply other threads:[~2019-03-22 16:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-18 23:04 Aditya Pakki
2019-03-22 16:44 ` Steven Price [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6053ea18-f092-bb4a-fe0a-a40eda1abfdd@arm.com \
--to=steven.price@arm.com \
--cc=kjlu@umn.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pakki001@umn.edu \
--cc=sudeep.holla@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®