lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20151116121445.GC22022@pengutronix.de>
Date:	Mon, 16 Nov 2015 13:14:45 +0100
From:	Uwe Kleine-König 
	<u.kleine-koenig@...gutronix.de>
To:	LABBE Corentin <clabbe.montjoie@...il.com>
Cc:	gregkh@...uxfoundation.org, jslaby@...e.com,
	linux-kernel@...r.kernel.org, linux-serial@...r.kernel.org
Subject: Re: [PATCH] serial: imx: fix a possible NULL dereference

Hello,

On Thu, Nov 12, 2015 at 08:46:21AM +0100, LABBE Corentin wrote:
> of_match_device could return NULL, and so cause a NULL pointer
> dereference later.
> 
> Signed-off-by: LABBE Corentin <clabbe.montjoie@...il.com>
> ---
>  drivers/tty/serial/imx.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index 016e4be..22e91f7 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> @@ -1857,8 +1857,7 @@ static int serial_imx_probe_dt(struct imx_port *sport,
>  		struct platform_device *pdev)
>  {
>  	struct device_node *np = pdev->dev.of_node;
> -	const struct of_device_id *of_id =
> -			of_match_device(imx_uart_dt_ids, &pdev->dev);
> +	const struct of_device_id *of_id;
>  	int ret;
>  
>  	if (!np)
> @@ -1878,6 +1877,9 @@ static int serial_imx_probe_dt(struct imx_port *sport,
>  	if (of_get_property(np, "fsl,dte-mode", NULL))
>  		sport->dte_mode = 1;
>  
> +	of_id = of_match_device(imx_uart_dt_ids, &pdev->dev);
> +	if (!of_id)
> +		return -ENODEV;
>  	sport->devdata = of_id->data;
>  
>  	return 0;

I'd do something like:

-	if (!np)
+	sport->devdata = of_device_get_match_data(&pdev->dev);
+	if (!sport->devdata)
 		/* no device tree device */
 		return 1;

instead.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ