Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1575596

Re: [PATCH] Mfd - Fix possible NULL derefrence.

From Andy Shevchenko <andy.shevchenko@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH] Mfd - Fix possible NULL derefrence.
Date 2017-02-07 13:00 +0100
Message-ID <t8cBc-2ms-19@gated-at.bofh.it> (permalink)
References <t4cJv-3oK-99@gated-at.bofh.it> <t4cJv-3oK-97@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, Jan 27, 2017 at 1:16 PM, Shailendra Verma
<shailendra.v@samsung.com> wrote:
> of_match_device could return NULL, and so can cause a NULL
> pointer dereference later.

I think it's not possible.

> --- 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);
> --
> 1.7.9.5
>



-- 
With Best Regards,
Andy Shevchenko

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

Re: [PATCH] Mfd - Fix possible NULL derefrence. Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-02-07 13:00 +0100

csiph-web