public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mfd: add null check before pointer dereference
@ 2017-05-24  8:37 Gustavo A. R. Silva
  2017-05-24  8:42 ` Charles Keepax
  2017-05-24  9:26 ` [PATCH v2] mfd: wm831x: " Gustavo A. R. Silva
  0 siblings, 2 replies; 6+ messages in thread
From: Gustavo A. R. Silva @ 2017-05-24  8:37 UTC (permalink / raw)
  To: Lee Jones, Charles Keepax; +Cc: patches, linux-kernel, Gustavo A. R. Silva

Add NULL check before dereferencing pointer of_id in order to avoid
a potential NULL pointer dereference.

Addresses-Coverity-ID: 1408829
Cc: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
 drivers/mfd/wm831x-i2c.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/mfd/wm831x-i2c.c b/drivers/mfd/wm831x-i2c.c
index 781af06..2d48f41 100644
--- a/drivers/mfd/wm831x-i2c.c
+++ b/drivers/mfd/wm831x-i2c.c
@@ -37,6 +37,10 @@ static int wm831x_i2c_probe(struct i2c_client *i2c,
 
 	if (i2c->dev.of_node) {
 		of_id = of_match_device(wm831x_of_match, &i2c->dev);
+		if (!of_id) {
+			dev_err(&i2c->dev, "Failed to find matching id\n");
+			return -EINVAL;
+		}
 		type = (enum wm831x_parent)of_id->data;
 	} else {
 		type = (enum wm831x_parent)id->driver_data;
-- 
2.5.0

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

* Re: [PATCH] mfd: add null check before pointer dereference
  2017-05-24  8:37 [PATCH] mfd: add null check before pointer dereference Gustavo A. R. Silva
@ 2017-05-24  8:42 ` Charles Keepax
  2017-05-24  9:26 ` [PATCH v2] mfd: wm831x: " Gustavo A. R. Silva
  1 sibling, 0 replies; 6+ messages in thread
From: Charles Keepax @ 2017-05-24  8:42 UTC (permalink / raw)
  To: Gustavo A. R. Silva; +Cc: Lee Jones, patches, linux-kernel

On Wed, May 24, 2017 at 03:37:58AM -0500, Gustavo A. R. Silva wrote:
> Add NULL check before dereferencing pointer of_id in order to avoid
> a potential NULL pointer dereference.
> 
> Addresses-Coverity-ID: 1408829
> Cc: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> ---

Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>

Thanks,
Charles

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

* [PATCH v2] mfd: wm831x: add null check before pointer dereference
  2017-05-24  8:50 [PATCH] mfd: " Gustavo A. R. Silva
@ 2017-05-24  9:18 ` Gustavo A. R. Silva
  2017-05-24 10:52   ` Lee Jones
  0 siblings, 1 reply; 6+ messages in thread
From: Gustavo A. R. Silva @ 2017-05-24  9:18 UTC (permalink / raw)
  To: Lee Jones, Charles Keepax; +Cc: patches, linux-kernel, Gustavo A. R. Silva

Add NULL check before dereferencing pointer of_id in order to avoid
a potential NULL pointer dereference.

Addresses-Coverity-ID: 1408830
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
Changes in v2:
 Update error log and return value.

 drivers/mfd/wm831x-spi.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/mfd/wm831x-spi.c b/drivers/mfd/wm831x-spi.c
index c332e28..018ce65 100644
--- a/drivers/mfd/wm831x-spi.c
+++ b/drivers/mfd/wm831x-spi.c
@@ -34,6 +34,10 @@ static int wm831x_spi_probe(struct spi_device *spi)
 
 	if (spi->dev.of_node) {
 		of_id = of_match_device(wm831x_of_match, &spi->dev);
+		if (!of_id) {
+			dev_err(&spi->dev, "Failed to match device\n");
+			return -ENODEV;
+		}
 		type = (enum wm831x_parent)of_id->data;
 	} else {
 		type = (enum wm831x_parent)id->driver_data;
-- 
2.5.0

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

* [PATCH v2] mfd: wm831x: add null check before pointer dereference
  2017-05-24  8:37 [PATCH] mfd: add null check before pointer dereference Gustavo A. R. Silva
  2017-05-24  8:42 ` Charles Keepax
@ 2017-05-24  9:26 ` Gustavo A. R. Silva
  2017-05-24 10:51   ` Lee Jones
  1 sibling, 1 reply; 6+ messages in thread
From: Gustavo A. R. Silva @ 2017-05-24  9:26 UTC (permalink / raw)
  To: Lee Jones, Charles Keepax; +Cc: patches, linux-kernel, Gustavo A. R. Silva

Add NULL check before dereferencing pointer of_id in order to avoid
a potential NULL pointer dereference.

Addresses-Coverity-ID: 1408829
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
Changes in v2:
 Update error log and return value.

 drivers/mfd/wm831x-i2c.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/mfd/wm831x-i2c.c b/drivers/mfd/wm831x-i2c.c
index 781af06..bed66d8 100644
--- a/drivers/mfd/wm831x-i2c.c
+++ b/drivers/mfd/wm831x-i2c.c
@@ -37,6 +37,10 @@ static int wm831x_i2c_probe(struct i2c_client *i2c,
 
 	if (i2c->dev.of_node) {
 		of_id = of_match_device(wm831x_of_match, &i2c->dev);
+		if (!of_id) {
+			dev_err(&i2c->dev, "Failed to match device\n");
+			return -ENODEV;
+		}
 		type = (enum wm831x_parent)of_id->data;
 	} else {
 		type = (enum wm831x_parent)id->driver_data;
-- 
2.5.0

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

* Re: [PATCH v2] mfd: wm831x: add null check before pointer dereference
  2017-05-24  9:26 ` [PATCH v2] mfd: wm831x: " Gustavo A. R. Silva
@ 2017-05-24 10:51   ` Lee Jones
  0 siblings, 0 replies; 6+ messages in thread
From: Lee Jones @ 2017-05-24 10:51 UTC (permalink / raw)
  To: Gustavo A. R. Silva; +Cc: Charles Keepax, patches, linux-kernel

On Wed, 24 May 2017, Gustavo A. R. Silva wrote:

> Add NULL check before dereferencing pointer of_id in order to avoid
> a potential NULL pointer dereference.
> 
> Addresses-Coverity-ID: 1408829
> Cc: Lee Jones <lee.jones@linaro.org>
> Cc: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> ---
> Changes in v2:
>  Update error log and return value.
> 
>  drivers/mfd/wm831x-i2c.c | 4 ++++
>  1 file changed, 4 insertions(+)

Applied, thanks.

> diff --git a/drivers/mfd/wm831x-i2c.c b/drivers/mfd/wm831x-i2c.c
> index 781af06..bed66d8 100644
> --- a/drivers/mfd/wm831x-i2c.c
> +++ b/drivers/mfd/wm831x-i2c.c
> @@ -37,6 +37,10 @@ static int wm831x_i2c_probe(struct i2c_client *i2c,
>  
>  	if (i2c->dev.of_node) {
>  		of_id = of_match_device(wm831x_of_match, &i2c->dev);
> +		if (!of_id) {
> +			dev_err(&i2c->dev, "Failed to match device\n");
> +			return -ENODEV;
> +		}
>  		type = (enum wm831x_parent)of_id->data;
>  	} else {
>  		type = (enum wm831x_parent)id->driver_data;

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

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

* Re: [PATCH v2] mfd: wm831x: add null check before pointer dereference
  2017-05-24  9:18 ` [PATCH v2] mfd: wm831x: " Gustavo A. R. Silva
@ 2017-05-24 10:52   ` Lee Jones
  0 siblings, 0 replies; 6+ messages in thread
From: Lee Jones @ 2017-05-24 10:52 UTC (permalink / raw)
  To: Gustavo A. R. Silva; +Cc: Charles Keepax, patches, linux-kernel

On Wed, 24 May 2017, Gustavo A. R. Silva wrote:

> Add NULL check before dereferencing pointer of_id in order to avoid
> a potential NULL pointer dereference.
> 
> Addresses-Coverity-ID: 1408830
> Cc: Lee Jones <lee.jones@linaro.org>
> Cc: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> ---
> Changes in v2:
>  Update error log and return value.
> 
>  drivers/mfd/wm831x-spi.c | 4 ++++
>  1 file changed, 4 insertions(+)

Applied, thanks.

> diff --git a/drivers/mfd/wm831x-spi.c b/drivers/mfd/wm831x-spi.c
> index c332e28..018ce65 100644
> --- a/drivers/mfd/wm831x-spi.c
> +++ b/drivers/mfd/wm831x-spi.c
> @@ -34,6 +34,10 @@ static int wm831x_spi_probe(struct spi_device *spi)
>  
>  	if (spi->dev.of_node) {
>  		of_id = of_match_device(wm831x_of_match, &spi->dev);
> +		if (!of_id) {
> +			dev_err(&spi->dev, "Failed to match device\n");
> +			return -ENODEV;
> +		}
>  		type = (enum wm831x_parent)of_id->data;
>  	} else {
>  		type = (enum wm831x_parent)id->driver_data;

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

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

end of thread, other threads:[~2017-05-24 10:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-24  8:37 [PATCH] mfd: add null check before pointer dereference Gustavo A. R. Silva
2017-05-24  8:42 ` Charles Keepax
2017-05-24  9:26 ` [PATCH v2] mfd: wm831x: " Gustavo A. R. Silva
2017-05-24 10:51   ` Lee Jones
  -- strict thread matches above, loose matches on Subject: below --
2017-05-24  8:50 [PATCH] mfd: " Gustavo A. R. Silva
2017-05-24  9:18 ` [PATCH v2] mfd: wm831x: " Gustavo A. R. Silva
2017-05-24 10:52   ` Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox