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: <20190724185933.GE22640@ravnborg.org>
Date:   Wed, 24 Jul 2019 20:59:33 +0200
From:   Sam Ravnborg <sam@...nborg.org>
To:     Navid Emamdoost <navid.emamdoost@...il.com>
Cc:     emamd001@....edu, kjlu@....edu, smccaman@....edu,
        secalert@...hat.com, Thierry Reding <thierry.reding@...il.com>,
        David Airlie <airlied@...ux.ie>,
        Daniel Vetter <daniel@...ll.ch>,
        dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] drm/panel: check failure cases in the probe func

Hi Navid.

Thanks for your patch.

On Wed, Jul 24, 2019 at 09:48:44AM -0500, Navid Emamdoost wrote:
> The following function calls may fail and return NULL, so the null check
> is added.
> of_graph_get_next_endpoint
> of_graph_get_remote_port_parent
> of_graph_get_remote_port
> 
> Signed-off-by: Navid Emamdoost <navid.emamdoost@...il.com>
> ---
>  drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c b/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
> index 28c0620dfe0f..9484fdb60f68 100644
> --- a/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
> +++ b/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
> @@ -399,7 +399,13 @@ static int rpi_touchscreen_probe(struct i2c_client *i2c,
>  
>  	/* Look up the DSI host.  It needs to probe before we do. */
>  	endpoint = of_graph_get_next_endpoint(dev->of_node, NULL);
> +	if (!endpoint)
> +		return -ENODEV;
> +
>  	dsi_host_node = of_graph_get_remote_port_parent(endpoint);
> +	if (!dsi_host_node)
> +		return -ENODEV;
> +
If we return here we will leak endpoint - a of_node_put() is missing.
Use goto to rewind the allocations in the bottom of this function.

>  	host = of_find_mipi_dsi_host_by_node(dsi_host_node);
>  	of_node_put(dsi_host_node);
>  	if (!host) {
> @@ -408,6 +414,9 @@ static int rpi_touchscreen_probe(struct i2c_client *i2c,
>  	}
>  
>  	info.node = of_graph_get_remote_port(endpoint);
> +	if (!info.node)
> +		return -ENODEV;
Here we also leak endpoint, but not dsi_host_node as we already did a
put above.

> +
>  	of_node_put(endpoint);
>  
>  	ts->dsi = mipi_dsi_device_register_full(host, &info);

	Sam

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ