All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] spi - Fix possible NULL derefrence.
       [not found] <CGME20170130045527epcas2p18ca90e9cd6b0a6153bf941eec4f40ddf@epcas2p1.samsung.com>
@ 2017-01-30  4:55   ` Shailendra Verma
  0 siblings, 0 replies; 6+ messages in thread
From: Shailendra Verma @ 2017-01-30  4:55 UTC (permalink / raw)
  To: Mark Brown, linux-spi, linux-kernel, p.shailesh, ashish.kalra,
	Shailendra Verma, Shailendra Verma

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] spi - Fix possible NULL derefrence.
@ 2017-01-30  4:55   ` Shailendra Verma
  0 siblings, 0 replies; 6+ messages in thread
From: Shailendra Verma @ 2017-01-30  4:55 UTC (permalink / raw)
  To: Mark Brown, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	p.shailesh-Sze3O3UU22JBDgjK7y7TUQ,
	ashish.kalra-Sze3O3UU22JBDgjK7y7TUQ, Shailendra Verma,
	Shailendra Verma

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

Signed-off-by: Shailendra Verma <shailendra.v-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] spi - Fix possible NULL derefrence.
@ 2017-01-30 10:00     ` Geert Uytterhoeven
  0 siblings, 0 replies; 6+ messages in thread
From: Geert Uytterhoeven @ 2017-01-30 10:00 UTC (permalink / raw)
  To: Shailendra Verma
  Cc: Mark Brown, linux-spi, linux-kernel, p.shailesh, ashish.kalra,
	Shailendra Verma

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] spi - Fix possible NULL derefrence.
@ 2017-01-30 10:00     ` Geert Uytterhoeven
  0 siblings, 0 replies; 6+ messages in thread
From: Geert Uytterhoeven @ 2017-01-30 10:00 UTC (permalink / raw)
  To: Shailendra Verma
  Cc: Mark Brown, linux-spi, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	p.shailesh-Sze3O3UU22JBDgjK7y7TUQ,
	ashish.kalra-Sze3O3UU22JBDgjK7y7TUQ, Shailendra Verma

Hi Shailendra,

On Mon, Jan 30, 2017 at 5:55 AM, Shailendra Verma
<shailendra.v-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> 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-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
> ---
>  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-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.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
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] spi - Fix possible NULL derefrence.
@ 2017-01-30 12:52       ` Mark Brown
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2017-01-30 12:52 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Shailendra Verma, linux-spi, linux-kernel, p.shailesh,
	ashish.kalra, Shailendra Verma

[-- Attachment #1: Type: text/plain, Size: 542 bytes --]

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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] spi - Fix possible NULL derefrence.
@ 2017-01-30 12:52       ` Mark Brown
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2017-01-30 12:52 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Shailendra Verma, linux-spi, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	p.shailesh-Sze3O3UU22JBDgjK7y7TUQ,
	ashish.kalra-Sze3O3UU22JBDgjK7y7TUQ, Shailendra Verma

[-- Attachment #1: Type: text/plain, Size: 570 bytes --]

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-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> 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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-01-30 13:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20170130045527epcas2p18ca90e9cd6b0a6153bf941eec4f40ddf@epcas2p1.samsung.com>
2017-01-30  4:55 ` [PATCH] spi - Fix possible NULL derefrence Shailendra Verma
2017-01-30  4:55   ` Shailendra Verma
2017-01-30 10:00   ` Geert Uytterhoeven
2017-01-30 10:00     ` Geert Uytterhoeven
2017-01-30 12:52     ` Mark Brown
2017-01-30 12:52       ` Mark Brown

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.