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


Groups > linux.kernel > #1569389 > unrolled thread

[PATCH] spi - Fix possible NULL derefrence.

Started byShailendra Verma <shailendra.v@samsung.com>
First post2017-01-30 06:00 +0100
Last post2017-01-30 14:20 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH] spi - Fix possible NULL derefrence. Shailendra Verma <shailendra.v@samsung.com> - 2017-01-30 06:00 +0100
    Re: [PATCH] spi - Fix possible NULL derefrence. Geert Uytterhoeven <geert@linux-m68k.org> - 2017-01-30 11:10 +0100
      Re: [PATCH] spi - Fix possible NULL derefrence. Mark Brown <broonie@kernel.org> - 2017-01-30 14:20 +0100

#1569389 — [PATCH] spi - Fix possible NULL derefrence.

FromShailendra Verma <shailendra.v@samsung.com>
Date2017-01-30 06:00 +0100
Subject[PATCH] spi - Fix possible NULL derefrence.
Message-ID<t5cem-804-21@gated-at.bofh.it>
of_match_device could return NULL, and so can cause a NULL
pointer dereference later.

Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
---
 drivers/spi/spi-mxs.c |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/spi/spi-mxs.c b/drivers/spi/spi-mxs.c
index 5b0e9a3..c3aea7e 100644
--- a/drivers/spi/spi-mxs.c
+++ b/drivers/spi/spi-mxs.c
@@ -470,6 +470,11 @@ static int mxs_spi_probe(struct platform_device *pdev)
 	 */
 	const int clk_freq_default = 160000000;
 
+	if (!of_id) {
+		dev_err(&pdev->dev, "Error: No device match found\n");
+		return -ENODEV;
+	}
+
 	iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	irq_err = platform_get_irq(pdev, 0);
 	if (irq_err < 0)
-- 
1.7.9.5

[toc] | [next] | [standalone]


#1569522

FromGeert Uytterhoeven <geert@linux-m68k.org>
Date2017-01-30 11:10 +0100
Message-ID<t5h4l-2H9-13@gated-at.bofh.it>
In reply to#1569389
Hi Shailendra,

On Mon, Jan 30, 2017 at 5:55 AM, Shailendra Verma
<shailendra.v@samsung.com> wrote:
> of_match_device could return NULL, and so can cause a NULL
> pointer dereference later.

Can it? The driver uses DT exclusively.
There is no legacy platform code creating "mxs-spi" platform devices.

> Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
> ---
>  drivers/spi/spi-mxs.c |    5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/spi/spi-mxs.c b/drivers/spi/spi-mxs.c
> index 5b0e9a3..c3aea7e 100644
> --- a/drivers/spi/spi-mxs.c
> +++ b/drivers/spi/spi-mxs.c
> @@ -470,6 +470,11 @@ static int mxs_spi_probe(struct platform_device *pdev)
>          */
>         const int clk_freq_default = 160000000;
>
> +       if (!of_id) {
> +               dev_err(&pdev->dev, "Error: No device match found\n");
> +               return -ENODEV;
> +       }
> +

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

[toc] | [prev] | [next] | [standalone]


#1569728

FromMark Brown <broonie@kernel.org>
Date2017-01-30 14:20 +0100
Message-ID<t5k2e-4rq-3@gated-at.bofh.it>
In reply to#1569522

[Multipart message — attachments visible in raw view] — view raw

On Mon, Jan 30, 2017 at 11:00:28AM +0100, Geert Uytterhoeven wrote:
> On Mon, Jan 30, 2017 at 5:55 AM, Shailendra Verma
> <shailendra.v@samsung.com> wrote:
> > of_match_device could return NULL, and so can cause a NULL
> > pointer dereference later.

> Can it? The driver uses DT exclusively.
> There is no legacy platform code creating "mxs-spi" platform devices.

Yeah, the changelogs on these aren't very good - there's no present
risk, though future changes could potentially cause an issue so it's not
unreasonable to do it defensively.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web