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


Groups > linux.kernel > #1568107 > unrolled thread

[PATCH] Tty: serial - Fix possible NULL derefrence.

Started byShailendra Verma <shailendra.v@samsung.com>
First post2017-01-27 12:20 +0100
Last post2017-01-27 12: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] Tty: serial - Fix possible NULL derefrence. Shailendra Verma <shailendra.v@samsung.com> - 2017-01-27 12:20 +0100
    Re: [PATCH] Tty: serial - Fix possible NULL derefrence. Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-01-27 12:40 +0100

#1568107 — [PATCH] Tty: serial - Fix possible NULL derefrence.

FromShailendra Verma <shailendra.v@samsung.com>
Date2017-01-27 12:20 +0100
Subject[PATCH] Tty: serial - Fix possible NULL derefrence.
Message-ID<t4cJs-3oK-5@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/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

[toc] | [next] | [standalone]


#1568191

FromGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Date2017-01-27 12:40 +0100
Message-ID<t4d2N-3w5-1@gated-at.bofh.it>
In reply to#1568107
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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web