linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Tty: serial - Fix possible NULL derefrence.
       [not found] <CGME20170127111619epcas4p44c21059f85b7aa091016019c98d42939@epcas4p4.samsung.com>
@ 2017-01-27 11:16 ` Shailendra Verma
  2017-01-27 11:31   ` Greg Kroah-Hartman
  2017-01-30 19:37   ` Greg Kroah-Hartman
  0 siblings, 2 replies; 5+ messages in thread
From: Shailendra Verma @ 2017-01-27 11:16 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, linux-serial, 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/tty/serial/max310x.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
index 8a3e926..a94d147 100644
--- a/drivers/tty/serial/max310x.c
+++ b/drivers/tty/serial/max310x.c
@@ -1323,6 +1323,10 @@ static int max310x_spi_probe(struct spi_device *spi)
 	if (spi->dev.of_node) {
 		const struct of_device_id *of_id =
 			of_match_device(max310x_dt_ids, &spi->dev);
+		if (!of_id) {
+			dev_err(&spi->dev, "Error: No device match found\n");
+			return -ENODEV;
+		}
 
 		devtype = (struct max310x_devtype *)of_id->data;
 	} else {
-- 
1.7.9.5

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

* Re: [PATCH] Tty: serial - Fix possible NULL derefrence.
  2017-01-27 11:16 ` [PATCH] Tty: serial - Fix possible NULL derefrence Shailendra Verma
@ 2017-01-27 11:31   ` Greg Kroah-Hartman
  2017-01-30 19:37   ` Greg Kroah-Hartman
  1 sibling, 0 replies; 5+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-27 11:31 UTC (permalink / raw)
  To: Shailendra Verma
  Cc: Jiri Slaby, linux-serial, linux-kernel, p.shailesh, ashish.kalra,
	Shailendra Verma

On Fri, Jan 27, 2017 at 04:46:13PM +0530, Shailendra Verma wrote:
> 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/tty/serial/max310x.c |    4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
> index 8a3e926..a94d147 100644
> --- a/drivers/tty/serial/max310x.c
> +++ b/drivers/tty/serial/max310x.c
> @@ -1323,6 +1323,10 @@ static int max310x_spi_probe(struct spi_device *spi)
>  	if (spi->dev.of_node) {
>  		const struct of_device_id *of_id =
>  			of_match_device(max310x_dt_ids, &spi->dev);
> +		if (!of_id) {
> +			dev_err(&spi->dev, "Error: No device match found\n");
> +			return -ENODEV;
> +		}

Have you ever hit this with a "real" system?

thanks,

greg k-h

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

* Re: [PATCH] Tty: serial - Fix possible NULL derefrence.
  2017-01-27 11:16 ` [PATCH] Tty: serial - Fix possible NULL derefrence Shailendra Verma
  2017-01-27 11:31   ` Greg Kroah-Hartman
@ 2017-01-30 19:37   ` Greg Kroah-Hartman
  2017-02-18 10:25     ` Maarten Brock
  1 sibling, 1 reply; 5+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-30 19:37 UTC (permalink / raw)
  To: Shailendra Verma
  Cc: Jiri Slaby, linux-serial, linux-kernel, p.shailesh, ashish.kalra,
	Shailendra Verma

On Fri, Jan 27, 2017 at 04:46:13PM +0530, Shailendra Verma wrote:
> 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/tty/serial/max310x.c |    4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
> index 8a3e926..a94d147 100644
> --- a/drivers/tty/serial/max310x.c
> +++ b/drivers/tty/serial/max310x.c
> @@ -1323,6 +1323,10 @@ static int max310x_spi_probe(struct spi_device *spi)
>  	if (spi->dev.of_node) {
>  		const struct of_device_id *of_id =
>  			of_match_device(max310x_dt_ids, &spi->dev);
> +		if (!of_id) {
> +			dev_err(&spi->dev, "Error: No device match found\n");
> +			return -ENODEV;
> +		}

Patch now dropped as this isn't possible.

thanks,

greg k-h

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

* Re: [PATCH] Tty: serial - Fix possible NULL derefrence.
  2017-01-30 19:37   ` Greg Kroah-Hartman
@ 2017-02-18 10:25     ` Maarten Brock
  2017-02-18 13:06       ` Greg Kroah-Hartman
  0 siblings, 1 reply; 5+ messages in thread
From: Maarten Brock @ 2017-02-18 10:25 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Shailendra Verma, Jiri Slaby, linux-serial, linux-kernel,
	p.shailesh, ashish.kalra, Shailendra Verma, linux-serial-owner

Hello Greg,

Does that also mean that this isn't possible in the sc16is7xx.c driver 
in
sc16is7xx_spi_probe() line 1358 and sc16is7xx_i2c_probe() line 1419 ?

If so, should these checks be removed?

Kind regards,
Maarten

On 2017-01-30 20:37, Greg Kroah-Hartman wrote:
> On Fri, Jan 27, 2017 at 04:46:13PM +0530, Shailendra Verma wrote:
>> 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/tty/serial/max310x.c |    4 ++++
>>  1 file changed, 4 insertions(+)
>> 
>> diff --git a/drivers/tty/serial/max310x.c 
>> b/drivers/tty/serial/max310x.c
>> index 8a3e926..a94d147 100644
>> --- a/drivers/tty/serial/max310x.c
>> +++ b/drivers/tty/serial/max310x.c
>> @@ -1323,6 +1323,10 @@ static int max310x_spi_probe(struct spi_device 
>> *spi)
>>  	if (spi->dev.of_node) {
>>  		const struct of_device_id *of_id =
>>  			of_match_device(max310x_dt_ids, &spi->dev);
>> +		if (!of_id) {
>> +			dev_err(&spi->dev, "Error: No device match found\n");
>> +			return -ENODEV;
>> +		}
> 
> Patch now dropped as this isn't possible.
> 
> thanks,
> 
> greg k-h
> --
> To unsubscribe from this list: send the line "unsubscribe linux-serial" 
> in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] Tty: serial - Fix possible NULL derefrence.
  2017-02-18 10:25     ` Maarten Brock
@ 2017-02-18 13:06       ` Greg Kroah-Hartman
  0 siblings, 0 replies; 5+ messages in thread
From: Greg Kroah-Hartman @ 2017-02-18 13:06 UTC (permalink / raw)
  To: Maarten Brock
  Cc: Shailendra Verma, Jiri Slaby, linux-serial, linux-kernel,
	p.shailesh, ashish.kalra, Shailendra Verma, linux-serial-owner

On Sat, Feb 18, 2017 at 11:25:19AM +0100, Maarten Brock wrote:
> Hello Greg,
> 
> Does that also mean that this isn't possible in the sc16is7xx.c driver in
> sc16is7xx_spi_probe() line 1358 and sc16is7xx_i2c_probe() line 1419 ?
> 
> If so, should these checks be removed?

Probably.

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

end of thread, other threads:[~2017-02-18 13:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20170127111619epcas4p44c21059f85b7aa091016019c98d42939@epcas4p4.samsung.com>
2017-01-27 11:16 ` [PATCH] Tty: serial - Fix possible NULL derefrence Shailendra Verma
2017-01-27 11:31   ` Greg Kroah-Hartman
2017-01-30 19:37   ` Greg Kroah-Hartman
2017-02-18 10:25     ` Maarten Brock
2017-02-18 13:06       ` Greg Kroah-Hartman

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).