The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: Shailendra Verma <shailendra.v@samsung.com>
Cc: linux-kernel@vger.kernel.org, p.shailesh@samsung.com,
	ashish.kalra@samsung.com,
	Shailendra Verma <shailendra.capricorn@gmail.com>
Subject: Re: [PATCH] Mfd - Fix possible NULL derefrence.
Date: Tue, 7 Feb 2017 16:32:21 +0000	[thread overview]
Message-ID: <20170207163221.jvvbctrqjsjxkldw@dell> (raw)
In-Reply-To: <1485515805-3598-1-git-send-email-shailendra.v@samsung.com>

On Fri, 27 Jan 2017, Shailendra Verma wrote:

> of_match_device could return NULL, and so can cause a NULL
> pointer dereference later.

I don't think it can.

Did this actually happen to you?

> Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
> ---
>  drivers/mfd/mc13xxx-i2c.c |    4 ++++
>  drivers/mfd/mc13xxx-spi.c |    5 ++++-
>  2 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mfd/mc13xxx-i2c.c b/drivers/mfd/mc13xxx-i2c.c
> index 67e4c9a..e03f454 100644
> --- a/drivers/mfd/mc13xxx-i2c.c
> +++ b/drivers/mfd/mc13xxx-i2c.c
> @@ -80,6 +80,10 @@ static int mc13xxx_i2c_probe(struct i2c_client *client,
>  	if (client->dev.of_node) {
>  		const struct of_device_id *of_id =
>  			of_match_device(mc13xxx_dt_ids, &client->dev);
> +		if (!of_id) {
> +			dev_err(&client->dev, "Error: No device match found\n");
> +			return -ENODEV;
> +		}
>  		mc13xxx->variant = of_id->data;
>  	} else {
>  		mc13xxx->variant = (void *)id->driver_data;
> diff --git a/drivers/mfd/mc13xxx-spi.c b/drivers/mfd/mc13xxx-spi.c
> index cbc1e5e..97ab19c 100644
> --- a/drivers/mfd/mc13xxx-spi.c
> +++ b/drivers/mfd/mc13xxx-spi.c
> @@ -157,7 +157,10 @@ static int mc13xxx_spi_probe(struct spi_device *spi)
>  	if (spi->dev.of_node) {
>  		const struct of_device_id *of_id =
>  			of_match_device(mc13xxx_dt_ids, &spi->dev);
> +		if (!of_id) {
> +			dev_err(&spi->dev, "Error: No device match found\n");
> +			return -ENODEV;
> +		}
>  		mc13xxx->variant = of_id->data;
>  	} else {
>  		const struct spi_device_id *id_entry = spi_get_device_id(spi);

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

      parent reply	other threads:[~2017-02-07 16:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20170127111654epcas1p34aa51a351ad04a35b68a1fc88438fc27@epcas1p3.samsung.com>
2017-01-27 11:16 ` [PATCH] Mfd - Fix possible NULL derefrence Shailendra Verma
2017-02-07 11:51   ` Andy Shevchenko
2017-02-07 16:32   ` Lee Jones [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=20170207163221.jvvbctrqjsjxkldw@dell \
    --to=lee.jones@linaro.org \
    --cc=ashish.kalra@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=p.shailesh@samsung.com \
    --cc=shailendra.capricorn@gmail.com \
    --cc=shailendra.v@samsung.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