* [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; 8+ 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] 8+ 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; 8+ 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] 8+ 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; 8+ 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] 8+ 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; 8+ 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] 8+ messages in thread
* Re: [PATCH] mfd: add null check before pointer dereference
2017-05-24 8:43 ` Lee Jones
@ 2017-05-24 8:50 ` Gustavo A. R. Silva
0 siblings, 0 replies; 8+ messages in thread
From: Gustavo A. R. Silva @ 2017-05-24 8:50 UTC (permalink / raw)
To: Lee Jones; +Cc: Charles Keepax, patches, linux-kernel
Hi Lee,
Quoting Lee Jones <lee.jones@linaro.org>:
> Please use the $SUBJECT line expected by the subsystem.
>
> The following command can help with this:
>
> `git log --oneline -- <SUBSYSTEM>`
>
I get it.
>> Add null check before dereferencing pointer of_id in order to avoid
>> a potential NULL pointer dereference.
>>
>> Addresses-Coverity-ID: 1408830
>> Cc: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
>> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
>> ---
>> 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..7b227c9 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 find matching id\n");
>> + return -EINVAL;
>> + }
>
> I already mentioned why this isn't suitable.
>
> Please see my pre-review.
>
You are right. Let me fix that.
Thanks
--
Gustavo A. R. Silva
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] mfd: add null check before pointer dereference
2017-05-24 8:27 ` [PATCH] mfd: add null check before " Gustavo A. R. Silva
2017-05-24 8:41 ` Charles Keepax
@ 2017-05-24 8:43 ` Lee Jones
2017-05-24 8:50 ` Gustavo A. R. Silva
1 sibling, 1 reply; 8+ messages in thread
From: Lee Jones @ 2017-05-24 8:43 UTC (permalink / raw)
To: Gustavo A. R. Silva; +Cc: Charles Keepax, patches, linux-kernel
Please use the $SUBJECT line expected by the subsystem.
The following command can help with this:
`git log --oneline -- <SUBSYSTEM>`
> Add null check before dereferencing pointer of_id in order to avoid
> a potential NULL pointer dereference.
>
> Addresses-Coverity-ID: 1408830
> Cc: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> ---
> 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..7b227c9 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 find matching id\n");
> + return -EINVAL;
> + }
I already mentioned why this isn't suitable.
Please see my pre-review.
> 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] 8+ messages in thread
* Re: [PATCH] mfd: add null check before pointer dereference
2017-05-24 8:27 ` [PATCH] mfd: add null check before " Gustavo A. R. Silva
@ 2017-05-24 8:41 ` Charles Keepax
2017-05-24 8:43 ` Lee Jones
1 sibling, 0 replies; 8+ messages in thread
From: Charles Keepax @ 2017-05-24 8:41 UTC (permalink / raw)
To: Gustavo A. R. Silva; +Cc: Lee Jones, patches, linux-kernel
On Wed, May 24, 2017 at 03:27:31AM -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: 1408830
> 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>
Looks good although is there not probably the same issue in
wm831x-i2c.c? Might be worth fixing up both of them.
Thanks,
Charles
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] mfd: add null check before pointer dereference
2017-05-24 8:19 [mfd] question about potential null " Gustavo A. R. Silva
@ 2017-05-24 8:27 ` Gustavo A. R. Silva
2017-05-24 8:41 ` Charles Keepax
2017-05-24 8:43 ` Lee Jones
0 siblings, 2 replies; 8+ messages in thread
From: Gustavo A. R. Silva @ 2017-05-24 8:27 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: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
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..7b227c9 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 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] 8+ messages in thread
end of thread, other threads:[~2017-05-24 10:53 UTC | newest]
Thread overview: 8+ 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:19 [mfd] question about potential null " Gustavo A. R. Silva
2017-05-24 8:27 ` [PATCH] mfd: add null check before " Gustavo A. R. Silva
2017-05-24 8:41 ` Charles Keepax
2017-05-24 8:43 ` Lee Jones
2017-05-24 8:50 ` Gustavo A. R. Silva
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).