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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190309095803.edauvethw232h45t@uno.localdomain>
Date:   Sat, 9 Mar 2019 10:58:03 +0100
From:   Jacopo Mondi <jacopo@...ndi.org>
To:     Kangjie Lu <kjlu@....edu>
Cc:     pakki001@....edu, Mauro Carvalho Chehab <mchehab@...nel.org>,
        linux-media@...r.kernel.org, linux-renesas-soc@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] media: renesas-ceu: fix a potential NULL pointer
 dereference

Hi Kangjie,
   thanks for the patch.

On Sat, Mar 09, 2019 at 01:14:24AM -0600, Kangjie Lu wrote:
> In case of_match_device cannot find a match, the check returns
> -EINVAL to avoid a potential NULL pointer dereference
>
> Signed-off-by: Kangjie Lu <kjlu@....edu>
> ---
>  drivers/media/platform/renesas-ceu.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/renesas-ceu.c b/drivers/media/platform/renesas-ceu.c
> index 150196f7cf96..4aa807c0b6c7 100644
> --- a/drivers/media/platform/renesas-ceu.c
> +++ b/drivers/media/platform/renesas-ceu.c
> @@ -1682,7 +1682,10 @@ static int ceu_probe(struct platform_device *pdev)
>
>  	if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
>  		ceu_data = of_match_device(ceu_of_match, dev)->data;
> -		num_subdevs = ceu_parse_dt(ceudev);
> +		if (unlikely(!ceu_data))
> +			num_subdevs = -EINVAL;
> +		else
> +			num_subdevs = ceu_parse_dt(ceudev);

I don't think this fix is required to be honest.

If we call of_match_device() here we're sure CONFIG_OF is enabled, and
if the driver probed, so a matching compatible string has proved to
exist.

Furthermore, if you want to protect against of_match_device()
returning a NULL pointer, you should change this line first, as it
would dereference an invalid pointer:

  		ceu_data = of_match_device(ceu_of_match, dev)->data;

but again, I don't think this might happen.

Thanks
   j

>  	} else if (dev->platform_data) {
>  		/* Assume SH4 if booting with platform data. */
>  		ceu_data = &ceu_data_sh4;
> --
> 2.17.1
>

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ