linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpio: syscon: fix a possible NULL dereference
@ 2015-11-05 16:02 LABBE Corentin
  2015-11-09  0:23 ` Alexandre Courbot
  2015-11-17 11:01 ` Linus Walleij
  0 siblings, 2 replies; 3+ messages in thread
From: LABBE Corentin @ 2015-11-05 16:02 UTC (permalink / raw)
  To: linus.walleij, gnurou; +Cc: linux-gpio, linux-kernel, LABBE Corentin

of_match_device could return NULL, and so cause a NULL pointer
dereference later at line 199:
priv->flags = of_id->data;

Reported-by: coverity (CID 1324140)
Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
---
 drivers/gpio/gpio-syscon.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpio/gpio-syscon.c b/drivers/gpio/gpio-syscon.c
index 045a952..e673c58 100644
--- a/drivers/gpio/gpio-syscon.c
+++ b/drivers/gpio/gpio-syscon.c
@@ -192,6 +192,9 @@ static int syscon_gpio_probe(struct platform_device *pdev)
 	struct device_node *np = dev->of_node;
 	int ret;
 
+	if (!of_id)
+		return -ENODEV;
+
 	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
-- 
2.4.10

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

* Re: [PATCH] gpio: syscon: fix a possible NULL dereference
  2015-11-05 16:02 [PATCH] gpio: syscon: fix a possible NULL dereference LABBE Corentin
@ 2015-11-09  0:23 ` Alexandre Courbot
  2015-11-17 11:01 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Alexandre Courbot @ 2015-11-09  0:23 UTC (permalink / raw)
  To: LABBE Corentin
  Cc: Linus Walleij, linux-gpio@vger.kernel.org,
	Linux Kernel Mailing List

On Fri, Nov 6, 2015 at 1:02 AM, LABBE Corentin
<clabbe.montjoie@gmail.com> wrote:
> of_match_device could return NULL, and so cause a NULL pointer
> dereference later at line 199:
> priv->flags = of_id->data;
>
> Reported-by: coverity (CID 1324140)
> Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>

Same (optional) suggestion as the 74xx-mmio patch.

Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>

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

* Re: [PATCH] gpio: syscon: fix a possible NULL dereference
  2015-11-05 16:02 [PATCH] gpio: syscon: fix a possible NULL dereference LABBE Corentin
  2015-11-09  0:23 ` Alexandre Courbot
@ 2015-11-17 11:01 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2015-11-17 11:01 UTC (permalink / raw)
  To: LABBE Corentin
  Cc: Alexandre Courbot, linux-gpio@vger.kernel.org,
	linux-kernel@vger.kernel.org

On Thu, Nov 5, 2015 at 5:02 PM, LABBE Corentin
<clabbe.montjoie@gmail.com> wrote:

> of_match_device could return NULL, and so cause a NULL pointer
> dereference later at line 199:
> priv->flags = of_id->data;
>
> Reported-by: coverity (CID 1324140)
> Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>

Patch applied with Alexandre's review tag.

Yours,
Linus Walleij

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

end of thread, other threads:[~2015-11-17 11:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-05 16:02 [PATCH] gpio: syscon: fix a possible NULL dereference LABBE Corentin
2015-11-09  0:23 ` Alexandre Courbot
2015-11-17 11:01 ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).