Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1568205 > unrolled thread

[PATCH] Misc: eeprom - Fix possible NULL derefrence.

Started byShailendra Verma <shailendra.v@samsung.com>
First post2017-01-27 12:40 +0100
Last post2017-01-30 20:40 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH] Misc: eeprom - Fix possible NULL derefrence. Shailendra Verma <shailendra.v@samsung.com> - 2017-01-27 12:40 +0100
    Re: [PATCH] Misc: eeprom - Fix possible NULL derefrence. Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-01-30 20:40 +0100

#1568205 — [PATCH] Misc: eeprom - Fix possible NULL derefrence.

FromShailendra Verma <shailendra.v@samsung.com>
Date2017-01-27 12:40 +0100
Subject[PATCH] Misc: eeprom - Fix possible NULL derefrence.
Message-ID<t4d2P-3w5-35@gated-at.bofh.it>
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/misc/eeprom/eeprom_93xx46.c |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/misc/eeprom/eeprom_93xx46.c b/drivers/misc/eeprom/eeprom_93xx46.c
index 94cc035..6555975 100644
--- a/drivers/misc/eeprom/eeprom_93xx46.c
+++ b/drivers/misc/eeprom/eeprom_93xx46.c
@@ -381,6 +381,11 @@ static int eeprom_93xx46_probe_dt(struct spi_device *spi)
 	enum of_gpio_flags of_flags;
 	int ret;
 
+	if (!of_id) {
+		dev_err(&spi->dev, "Error: No device match found\n");
+		return -ENODEV;
+	}
+
 	pd = devm_kzalloc(&spi->dev, sizeof(*pd), GFP_KERNEL);
 	if (!pd)
 		return -ENOMEM;
-- 
1.7.9.5

[toc] | [next] | [standalone]


#1570064

FromGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Date2017-01-30 20:40 +0100
Message-ID<t5pXY-7V1-19@gated-at.bofh.it>
In reply to#1568205
On Fri, Jan 27, 2017 at 04:42:31PM +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/misc/eeprom/eeprom_93xx46.c |    5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/misc/eeprom/eeprom_93xx46.c b/drivers/misc/eeprom/eeprom_93xx46.c
> index 94cc035..6555975 100644
> --- a/drivers/misc/eeprom/eeprom_93xx46.c
> +++ b/drivers/misc/eeprom/eeprom_93xx46.c
> @@ -381,6 +381,11 @@ static int eeprom_93xx46_probe_dt(struct spi_device *spi)
>  	enum of_gpio_flags of_flags;
>  	int ret;
>  
> +	if (!of_id) {
> +		dev_err(&spi->dev, "Error: No device match found\n");
> +		return -ENODEV;
> +	}
> +

Also dropped due to this not being possible.

greg k-h

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web