Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 234eab84 authored by Javier Martinez Canillas's avatar Javier Martinez Canillas Committed by Mauro Carvalho Chehab
Browse files

[media] exynos4-is: Check v4l2_of_parse_endpoint() return value



The v4l2_of_parse_endpoint() function can fail so check the return value.

Signed-off-by: default avatarJavier Martinez Canillas <javier@osg.samsung.com>
Acked-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent baf40b5f
Loading
Loading
Loading
Loading
+7 −1
Original line number Original line Diff line number Diff line
@@ -332,13 +332,19 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
	struct fimc_source_info *pd = &fmd->sensor[index].pdata;
	struct fimc_source_info *pd = &fmd->sensor[index].pdata;
	struct device_node *rem, *ep, *np;
	struct device_node *rem, *ep, *np;
	struct v4l2_of_endpoint endpoint;
	struct v4l2_of_endpoint endpoint;
	int ret;


	/* Assume here a port node can have only one endpoint node. */
	/* Assume here a port node can have only one endpoint node. */
	ep = of_get_next_child(port, NULL);
	ep = of_get_next_child(port, NULL);
	if (!ep)
	if (!ep)
		return 0;
		return 0;


	v4l2_of_parse_endpoint(ep, &endpoint);
	ret = v4l2_of_parse_endpoint(ep, &endpoint);
	if (ret) {
		of_node_put(ep);
		return ret;
	}

	if (WARN_ON(endpoint.base.port == 0) || index >= FIMC_MAX_SENSORS)
	if (WARN_ON(endpoint.base.port == 0) || index >= FIMC_MAX_SENSORS)
		return -EINVAL;
		return -EINVAL;


+7 −3
Original line number Original line Diff line number Diff line
@@ -736,6 +736,7 @@ static int s5pcsis_parse_dt(struct platform_device *pdev,
{
{
	struct device_node *node = pdev->dev.of_node;
	struct device_node *node = pdev->dev.of_node;
	struct v4l2_of_endpoint endpoint;
	struct v4l2_of_endpoint endpoint;
	int ret;


	if (of_property_read_u32(node, "clock-frequency",
	if (of_property_read_u32(node, "clock-frequency",
				 &state->clk_frequency))
				 &state->clk_frequency))
@@ -751,7 +752,9 @@ static int s5pcsis_parse_dt(struct platform_device *pdev,
		return -EINVAL;
		return -EINVAL;
	}
	}
	/* Get port node and validate MIPI-CSI channel id. */
	/* Get port node and validate MIPI-CSI channel id. */
	v4l2_of_parse_endpoint(node, &endpoint);
	ret = v4l2_of_parse_endpoint(node, &endpoint);
	if (ret)
		goto err;


	state->index = endpoint.base.port - FIMC_INPUT_MIPI_CSI2_0;
	state->index = endpoint.base.port - FIMC_INPUT_MIPI_CSI2_0;
	if (state->index >= CSIS_MAX_ENTITIES)
	if (state->index >= CSIS_MAX_ENTITIES)
@@ -764,9 +767,10 @@ static int s5pcsis_parse_dt(struct platform_device *pdev,
					"samsung,csis-wclk");
					"samsung,csis-wclk");


	state->num_lanes = endpoint.bus.mipi_csi2.num_data_lanes;
	state->num_lanes = endpoint.bus.mipi_csi2.num_data_lanes;
	of_node_put(node);


	return 0;
err:
	of_node_put(node);
	return ret;
}
}


static int s5pcsis_pm_resume(struct device *dev, bool runtime);
static int s5pcsis_pm_resume(struct device *dev, bool runtime);