rpi_touchscreen_probe: check for failure case
diff mbox series

Message ID 20190724025644.17163-1-navid.emamdoost@gmail.com
State New
Headers show
Series
  • rpi_touchscreen_probe: check for failure case
Related show

Commit Message

Navid Emamdoost July 24, 2019, 2:56 a.m. UTC
of_graph_get_next_endpoint may return NULL, so null check is needed.

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
 drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Sam Ravnborg July 24, 2019, 5:17 a.m. UTC | #1
Hi Navid.

Thanks for your patch.
On Tue, Jul 23, 2019 at 09:56:43PM -0500, Navid Emamdoost wrote:
> of_graph_get_next_endpoint may return NULL, so null check is needed.
> 
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>

The patch looks fine, but could you please audit the other calls in the
probe function. For example of_graph_get_remote_port_parent() may also
return NULL.
If you do this then we can have the error handling reviewed in one go,
and fixed in one patch.

	Sam

> ---
>  drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c b/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
> index 28c0620dfe0f..2e0977e26fab 100644
> --- a/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
> +++ b/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
> @@ -399,6 +399,8 @@ 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);
>  	host = of_find_mipi_dsi_host_by_node(dsi_host_node);
>  	of_node_put(dsi_host_node);
> -- 
> 2.17.1

Patch
diff mbox series

diff --git a/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c b/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
index 28c0620dfe0f..2e0977e26fab 100644
--- a/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
+++ b/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
@@ -399,6 +399,8 @@  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);
 	host = of_find_mipi_dsi_host_by_node(dsi_host_node);
 	of_node_put(dsi_host_node);