All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/8] [media] Check v4l2_of_parse_endpoint() ret val in all drivers
@ 2016-01-11 16:47 ` Javier Martinez Canillas
  0 siblings, 0 replies; 13+ messages in thread
From: Javier Martinez Canillas @ 2016-01-11 16:47 UTC (permalink / raw)
  To: linux-kernel
  Cc: Javier Martinez Canillas, Sakari Ailus, Nikhil Devshatwar,
	Kukjin Kim, Krzysztof Kozlowski, Andrzej Hajda,
	Mauro Carvalho Chehab, Guennadi Liakhovetski, linux-samsung-soc,
	Kyungmin Park, Sylwester Nawrocki, Sakari Ailus, Prabhakar",
	Ricardo Ribalda Delgado, Laurent Pinchart, Hans Verkuil,
	linux-arm-kernel, linux-media

Hello,

When discussing a patch [0] with Laurent Pinchart for another series I
mentioned to him that most callers of v4l2_of_parse_endpoint() weren't
checking the return value. This is likely due the function kernel-doc
stating incorrectly that the return value is always 0 but can return a
negative error code on failure.

This trivial patch series fixes the function kernel-doc and add proper
error checking in all the drivers that are currently not doing so.

This is the second version of the series that fixes some minot issues
pointed out by Sakari Ailus. The v1 of the series can be found in [1].

[0]: https://lkml.org/lkml/2016/1/6/307
[1]: https://lkml.org/lkml/2016/1/7/508

Best regards,
Javier

Changes in v2:
- Assign pdata to NULL in case v4l2_of_parse_endpoint() fails before kzalloc.
  Suggested by Sakari Ailus.
- Assign pdata to NULL in case v4l2_of_parse_endpoint() fails before kzalloc.
  Suggested by Sakari Ailus.

Javier Martinez Canillas (8):
  [media] v4l: of: Correct v4l2_of_parse_endpoint() kernel-doc
  [media] adv7604: Check v4l2_of_parse_endpoint() return value
  [media] s5c73m3: Check v4l2_of_parse_endpoint() return value
  [media] s5k5baf: Check v4l2_of_parse_endpoint() return value
  [media] tvp514x: Check v4l2_of_parse_endpoint() return value
  [media] tvp7002: Check v4l2_of_parse_endpoint() return value
  [media] exynos4-is: Check v4l2_of_parse_endpoint() return value
  [media] omap3isp: Check v4l2_of_parse_endpoint() return value

 drivers/media/i2c/adv7604.c                   |  7 ++++++-
 drivers/media/i2c/s5c73m3/s5c73m3-core.c      |  4 +++-
 drivers/media/i2c/s5k5baf.c                   |  5 ++++-
 drivers/media/i2c/tvp514x.c                   |  6 ++++--
 drivers/media/i2c/tvp7002.c                   |  6 ++++--
 drivers/media/platform/exynos4-is/media-dev.c |  8 +++++++-
 drivers/media/platform/exynos4-is/mipi-csis.c | 10 +++++++---
 drivers/media/platform/omap3isp/isp.c         |  5 ++++-
 drivers/media/v4l2-core/v4l2-of.c             |  2 +-
 9 files changed, 40 insertions(+), 13 deletions(-)

-- 
2.4.3

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v2 0/8] [media] Check v4l2_of_parse_endpoint() ret val in all drivers
@ 2016-01-11 16:47 ` Javier Martinez Canillas
  0 siblings, 0 replies; 13+ messages in thread
From: Javier Martinez Canillas @ 2016-01-11 16:47 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

When discussing a patch [0] with Laurent Pinchart for another series I
mentioned to him that most callers of v4l2_of_parse_endpoint() weren't
checking the return value. This is likely due the function kernel-doc
stating incorrectly that the return value is always 0 but can return a
negative error code on failure.

This trivial patch series fixes the function kernel-doc and add proper
error checking in all the drivers that are currently not doing so.

This is the second version of the series that fixes some minot issues
pointed out by Sakari Ailus. The v1 of the series can be found in [1].

[0]: https://lkml.org/lkml/2016/1/6/307
[1]: https://lkml.org/lkml/2016/1/7/508

Best regards,
Javier

Changes in v2:
- Assign pdata to NULL in case v4l2_of_parse_endpoint() fails before kzalloc.
  Suggested by Sakari Ailus.
- Assign pdata to NULL in case v4l2_of_parse_endpoint() fails before kzalloc.
  Suggested by Sakari Ailus.

Javier Martinez Canillas (8):
  [media] v4l: of: Correct v4l2_of_parse_endpoint() kernel-doc
  [media] adv7604: Check v4l2_of_parse_endpoint() return value
  [media] s5c73m3: Check v4l2_of_parse_endpoint() return value
  [media] s5k5baf: Check v4l2_of_parse_endpoint() return value
  [media] tvp514x: Check v4l2_of_parse_endpoint() return value
  [media] tvp7002: Check v4l2_of_parse_endpoint() return value
  [media] exynos4-is: Check v4l2_of_parse_endpoint() return value
  [media] omap3isp: Check v4l2_of_parse_endpoint() return value

 drivers/media/i2c/adv7604.c                   |  7 ++++++-
 drivers/media/i2c/s5c73m3/s5c73m3-core.c      |  4 +++-
 drivers/media/i2c/s5k5baf.c                   |  5 ++++-
 drivers/media/i2c/tvp514x.c                   |  6 ++++--
 drivers/media/i2c/tvp7002.c                   |  6 ++++--
 drivers/media/platform/exynos4-is/media-dev.c |  8 +++++++-
 drivers/media/platform/exynos4-is/mipi-csis.c | 10 +++++++---
 drivers/media/platform/omap3isp/isp.c         |  5 ++++-
 drivers/media/v4l2-core/v4l2-of.c             |  2 +-
 9 files changed, 40 insertions(+), 13 deletions(-)

-- 
2.4.3

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v2 1/8] [media] v4l: of: Correct v4l2_of_parse_endpoint() kernel-doc
  2016-01-11 16:47 ` Javier Martinez Canillas
  (?)
@ 2016-01-11 16:47 ` Javier Martinez Canillas
  -1 siblings, 0 replies; 13+ messages in thread
From: Javier Martinez Canillas @ 2016-01-11 16:47 UTC (permalink / raw)
  To: linux-kernel
  Cc: Javier Martinez Canillas, Sakari Ailus, Nikhil Devshatwar,
	Mauro Carvalho Chehab, Sylwester Nawrocki, Laurent Pinchart,
	Hans Verkuil, linux-media

The v4l2_of_parse_endpoint function kernel-doc says that the return value
is always 0. But that is not true since the function can fail and a error
negative code is returned on failure. So correct the kernel-doc to match.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---

Changes in v2: None

 drivers/media/v4l2-core/v4l2-of.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/v4l2-of.c b/drivers/media/v4l2-core/v4l2-of.c
index b27cbb1f5afe..93b33681776c 100644
--- a/drivers/media/v4l2-core/v4l2-of.c
+++ b/drivers/media/v4l2-core/v4l2-of.c
@@ -146,7 +146,7 @@ static void v4l2_of_parse_parallel_bus(const struct device_node *node,
  * variable without a low fixed limit. Please use
  * v4l2_of_alloc_parse_endpoint() in new drivers instead.
  *
- * Return: 0.
+ * Return: 0 on success or a negative error code on failure.
  */
 int v4l2_of_parse_endpoint(const struct device_node *node,
 			   struct v4l2_of_endpoint *endpoint)
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 2/8] [media] adv7604: Check v4l2_of_parse_endpoint() return value
  2016-01-11 16:47 ` Javier Martinez Canillas
  (?)
  (?)
@ 2016-01-11 16:47 ` Javier Martinez Canillas
  -1 siblings, 0 replies; 13+ messages in thread
From: Javier Martinez Canillas @ 2016-01-11 16:47 UTC (permalink / raw)
  To: linux-kernel
  Cc: Javier Martinez Canillas, Mauro Carvalho Chehab, Hans Verkuil,
	linux-media

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

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---

Changes in v2: None

 drivers/media/i2c/adv7604.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index f8dd7505b529..ed3eccd94285 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -2799,6 +2799,7 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
 	struct device_node *endpoint;
 	struct device_node *np;
 	unsigned int flags;
+	int ret;
 	u32 v;
 
 	np = state->i2c_clients[ADV76XX_PAGE_IO]->dev.of_node;
@@ -2808,7 +2809,11 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
 	if (!endpoint)
 		return -EINVAL;
 
-	v4l2_of_parse_endpoint(endpoint, &bus_cfg);
+	ret = v4l2_of_parse_endpoint(endpoint, &bus_cfg);
+	if (ret) {
+		of_node_put(endpoint);
+		return ret;
+	}
 
 	if (!of_property_read_u32(endpoint, "default-input", &v))
 		state->pdata.default_input = v;
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 3/8] [media] s5c73m3: Check v4l2_of_parse_endpoint() return value
  2016-01-11 16:47 ` Javier Martinez Canillas
                   ` (2 preceding siblings ...)
  (?)
@ 2016-01-11 16:47 ` Javier Martinez Canillas
  -1 siblings, 0 replies; 13+ messages in thread
From: Javier Martinez Canillas @ 2016-01-11 16:47 UTC (permalink / raw)
  To: linux-kernel
  Cc: Javier Martinez Canillas, Mauro Carvalho Chehab, Andrzej Hajda,
	Kyungmin Park, linux-media

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

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---

Changes in v2: None

 drivers/media/i2c/s5c73m3/s5c73m3-core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
index 57b3d27993a4..08af58fb8e7d 100644
--- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c
+++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
@@ -1639,8 +1639,10 @@ static int s5c73m3_get_platform_data(struct s5c73m3 *state)
 		return 0;
 	}
 
-	v4l2_of_parse_endpoint(node_ep, &ep);
+	ret = v4l2_of_parse_endpoint(node_ep, &ep);
 	of_node_put(node_ep);
+	if (ret)
+		return ret;
 
 	if (ep.bus_type != V4L2_MBUS_CSI2) {
 		dev_err(dev, "unsupported bus type\n");
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 4/8] [media] s5k5baf: Check v4l2_of_parse_endpoint() return value
  2016-01-11 16:47 ` Javier Martinez Canillas
                   ` (3 preceding siblings ...)
  (?)
@ 2016-01-11 16:47 ` Javier Martinez Canillas
  -1 siblings, 0 replies; 13+ messages in thread
From: Javier Martinez Canillas @ 2016-01-11 16:47 UTC (permalink / raw)
  To: linux-kernel
  Cc: Javier Martinez Canillas, Mauro Carvalho Chehab, Andrzej Hajda,
	Kyungmin Park, linux-media

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

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---

Changes in v2: None

 drivers/media/i2c/s5k5baf.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c
index fc3a5a8e6c9c..db82ed05792e 100644
--- a/drivers/media/i2c/s5k5baf.c
+++ b/drivers/media/i2c/s5k5baf.c
@@ -1868,8 +1868,11 @@ static int s5k5baf_parse_device_node(struct s5k5baf *state, struct device *dev)
 		return -EINVAL;
 	}
 
-	v4l2_of_parse_endpoint(node_ep, &ep);
+	ret = v4l2_of_parse_endpoint(node_ep, &ep);
 	of_node_put(node_ep);
+	if (ret)
+		return ret;
+
 	state->bus_type = ep.bus_type;
 
 	switch (state->bus_type) {
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 5/8] [media] tvp514x: Check v4l2_of_parse_endpoint() return value
  2016-01-11 16:47 ` Javier Martinez Canillas
                   ` (4 preceding siblings ...)
  (?)
@ 2016-01-11 16:47 ` Javier Martinez Canillas
  2016-01-13 10:39   ` Lad, Prabhakar
  -1 siblings, 1 reply; 13+ messages in thread
From: Javier Martinez Canillas @ 2016-01-11 16:47 UTC (permalink / raw)
  To: linux-kernel
  Cc: Javier Martinez Canillas, Mauro Carvalho Chehab, Sakari Ailus,
	Prabhakar",
	Ricardo Ribalda Delgado, Guennadi Liakhovetski, Hans Verkuil,
	linux-media

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

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>

---

Changes in v2:
- Assign pdata to NULL in case v4l2_of_parse_endpoint() fails before kzalloc.
  Suggested by Sakari Ailus.

 drivers/media/i2c/tvp514x.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c
index 7fa5f1e4fe37..7cdd94842938 100644
--- a/drivers/media/i2c/tvp514x.c
+++ b/drivers/media/i2c/tvp514x.c
@@ -1001,7 +1001,7 @@ static struct tvp514x_decoder tvp514x_dev = {
 static struct tvp514x_platform_data *
 tvp514x_get_pdata(struct i2c_client *client)
 {
-	struct tvp514x_platform_data *pdata;
+	struct tvp514x_platform_data *pdata = NULL;
 	struct v4l2_of_endpoint bus_cfg;
 	struct device_node *endpoint;
 	unsigned int flags;
@@ -1013,11 +1013,13 @@ tvp514x_get_pdata(struct i2c_client *client)
 	if (!endpoint)
 		return NULL;
 
+	if (v4l2_of_parse_endpoint(endpoint, &bus_cfg))
+		goto done;
+
 	pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
 	if (!pdata)
 		goto done;
 
-	v4l2_of_parse_endpoint(endpoint, &bus_cfg);
 	flags = bus_cfg.bus.parallel.flags;
 
 	if (flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH)
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 6/8] [media] tvp7002: Check v4l2_of_parse_endpoint() return value
  2016-01-11 16:47 ` Javier Martinez Canillas
                   ` (5 preceding siblings ...)
  (?)
@ 2016-01-11 16:47 ` Javier Martinez Canillas
  2016-01-13 10:40   ` Lad, Prabhakar
  -1 siblings, 1 reply; 13+ messages in thread
From: Javier Martinez Canillas @ 2016-01-11 16:47 UTC (permalink / raw)
  To: linux-kernel
  Cc: Javier Martinez Canillas, Mauro Carvalho Chehab, Sakari Ailus,
	Prabhakar",
	Ricardo Ribalda Delgado, Laurent Pinchart, Hans Verkuil,
	linux-media

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

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>

---

Changes in v2:
- Assign pdata to NULL in case v4l2_of_parse_endpoint() fails before kzalloc.
  Suggested by Sakari Ailus.

 drivers/media/i2c/tvp7002.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/tvp7002.c b/drivers/media/i2c/tvp7002.c
index 83c79fa5f61d..4df640c3aa40 100644
--- a/drivers/media/i2c/tvp7002.c
+++ b/drivers/media/i2c/tvp7002.c
@@ -894,7 +894,7 @@ static struct tvp7002_config *
 tvp7002_get_pdata(struct i2c_client *client)
 {
 	struct v4l2_of_endpoint bus_cfg;
-	struct tvp7002_config *pdata;
+	struct tvp7002_config *pdata = NULL;
 	struct device_node *endpoint;
 	unsigned int flags;
 
@@ -905,11 +905,13 @@ tvp7002_get_pdata(struct i2c_client *client)
 	if (!endpoint)
 		return NULL;
 
+	if (v4l2_of_parse_endpoint(endpoint, &bus_cfg))
+		goto done;
+
 	pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
 	if (!pdata)
 		goto done;
 
-	v4l2_of_parse_endpoint(endpoint, &bus_cfg);
 	flags = bus_cfg.bus.parallel.flags;
 
 	if (flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH)
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 7/8] [media] exynos4-is: Check v4l2_of_parse_endpoint() return value
  2016-01-11 16:47 ` Javier Martinez Canillas
@ 2016-01-11 16:47   ` Javier Martinez Canillas
  -1 siblings, 0 replies; 13+ messages in thread
From: Javier Martinez Canillas @ 2016-01-11 16:47 UTC (permalink / raw)
  To: linux-kernel
  Cc: Javier Martinez Canillas, Kukjin Kim, Mauro Carvalho Chehab,
	linux-samsung-soc, Kyungmin Park, Krzysztof Kozlowski,
	Sylwester Nawrocki, linux-arm-kernel, linux-media

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

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---

Changes in v2: None

 drivers/media/platform/exynos4-is/media-dev.c |  8 +++++++-
 drivers/media/platform/exynos4-is/mipi-csis.c | 10 +++++++---
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
index f3b2dd30ec77..662d4a5c584e 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -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 device_node *rem, *ep, *np;
 	struct v4l2_of_endpoint endpoint;
+	int ret;
 
 	/* Assume here a port node can have only one endpoint node. */
 	ep = of_get_next_child(port, NULL);
 	if (!ep)
 		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)
 		return -EINVAL;
 
diff --git a/drivers/media/platform/exynos4-is/mipi-csis.c b/drivers/media/platform/exynos4-is/mipi-csis.c
index ac5e50e595be..bd5c46c3d4b7 100644
--- a/drivers/media/platform/exynos4-is/mipi-csis.c
+++ b/drivers/media/platform/exynos4-is/mipi-csis.c
@@ -736,6 +736,7 @@ static int s5pcsis_parse_dt(struct platform_device *pdev,
 {
 	struct device_node *node = pdev->dev.of_node;
 	struct v4l2_of_endpoint endpoint;
+	int ret;
 
 	if (of_property_read_u32(node, "clock-frequency",
 				 &state->clk_frequency))
@@ -751,7 +752,9 @@ static int s5pcsis_parse_dt(struct platform_device *pdev,
 		return -EINVAL;
 	}
 	/* 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;
 	if (state->index >= CSIS_MAX_ENTITIES)
@@ -764,9 +767,10 @@ static int s5pcsis_parse_dt(struct platform_device *pdev,
 					"samsung,csis-wclk");
 
 	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);
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 7/8] [media] exynos4-is: Check v4l2_of_parse_endpoint() return value
@ 2016-01-11 16:47   ` Javier Martinez Canillas
  0 siblings, 0 replies; 13+ messages in thread
From: Javier Martinez Canillas @ 2016-01-11 16:47 UTC (permalink / raw)
  To: linux-arm-kernel

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

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---

Changes in v2: None

 drivers/media/platform/exynos4-is/media-dev.c |  8 +++++++-
 drivers/media/platform/exynos4-is/mipi-csis.c | 10 +++++++---
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
index f3b2dd30ec77..662d4a5c584e 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -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 device_node *rem, *ep, *np;
 	struct v4l2_of_endpoint endpoint;
+	int ret;
 
 	/* Assume here a port node can have only one endpoint node. */
 	ep = of_get_next_child(port, NULL);
 	if (!ep)
 		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)
 		return -EINVAL;
 
diff --git a/drivers/media/platform/exynos4-is/mipi-csis.c b/drivers/media/platform/exynos4-is/mipi-csis.c
index ac5e50e595be..bd5c46c3d4b7 100644
--- a/drivers/media/platform/exynos4-is/mipi-csis.c
+++ b/drivers/media/platform/exynos4-is/mipi-csis.c
@@ -736,6 +736,7 @@ static int s5pcsis_parse_dt(struct platform_device *pdev,
 {
 	struct device_node *node = pdev->dev.of_node;
 	struct v4l2_of_endpoint endpoint;
+	int ret;
 
 	if (of_property_read_u32(node, "clock-frequency",
 				 &state->clk_frequency))
@@ -751,7 +752,9 @@ static int s5pcsis_parse_dt(struct platform_device *pdev,
 		return -EINVAL;
 	}
 	/* 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;
 	if (state->index >= CSIS_MAX_ENTITIES)
@@ -764,9 +767,10 @@ static int s5pcsis_parse_dt(struct platform_device *pdev,
 					"samsung,csis-wclk");
 
 	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);
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 8/8] [media] omap3isp: Check v4l2_of_parse_endpoint() return value
  2016-01-11 16:47 ` Javier Martinez Canillas
                   ` (7 preceding siblings ...)
  (?)
@ 2016-01-11 16:47 ` Javier Martinez Canillas
  -1 siblings, 0 replies; 13+ messages in thread
From: Javier Martinez Canillas @ 2016-01-11 16:47 UTC (permalink / raw)
  To: linux-kernel
  Cc: Javier Martinez Canillas, Mauro Carvalho Chehab,
	Laurent Pinchart, linux-media

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

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

---

Changes in v2: None

 drivers/media/platform/omap3isp/isp.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c
index 79a0b953bba3..891e54394a1c 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -2235,8 +2235,11 @@ static int isp_of_parse_node(struct device *dev, struct device_node *node,
 	struct isp_bus_cfg *buscfg = &isd->bus;
 	struct v4l2_of_endpoint vep;
 	unsigned int i;
+	int ret;
 
-	v4l2_of_parse_endpoint(node, &vep);
+	ret = v4l2_of_parse_endpoint(node, &vep);
+	if (ret)
+		return ret;
 
 	dev_dbg(dev, "parsing endpoint %s, interface %u\n", node->full_name,
 		vep.base.port);
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 5/8] [media] tvp514x: Check v4l2_of_parse_endpoint() return value
  2016-01-11 16:47 ` [PATCH v2 5/8] [media] tvp514x: " Javier Martinez Canillas
@ 2016-01-13 10:39   ` Lad, Prabhakar
  0 siblings, 0 replies; 13+ messages in thread
From: Lad, Prabhakar @ 2016-01-13 10:39 UTC (permalink / raw)
  To: Javier Martinez Canillas
  Cc: LKML, Mauro Carvalho Chehab, Sakari Ailus,
	Ricardo Ribalda Delgado, Guennadi Liakhovetski, Hans Verkuil,
	linux-media

On Mon, Jan 11, 2016 at 4:47 PM, Javier Martinez Canillas
<javier@osg.samsung.com> wrote:
> The v4l2_of_parse_endpoint() function can fail so check the return value.
>
> Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
>
Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>

Regards,
--Prabhakar Lad

> ---
>
> Changes in v2:
> - Assign pdata to NULL in case v4l2_of_parse_endpoint() fails before kzalloc.
>   Suggested by Sakari Ailus.
>
>  drivers/media/i2c/tvp514x.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c
> index 7fa5f1e4fe37..7cdd94842938 100644
> --- a/drivers/media/i2c/tvp514x.c
> +++ b/drivers/media/i2c/tvp514x.c
> @@ -1001,7 +1001,7 @@ static struct tvp514x_decoder tvp514x_dev = {
>  static struct tvp514x_platform_data *
>  tvp514x_get_pdata(struct i2c_client *client)
>  {
> -       struct tvp514x_platform_data *pdata;
> +       struct tvp514x_platform_data *pdata = NULL;
>         struct v4l2_of_endpoint bus_cfg;
>         struct device_node *endpoint;
>         unsigned int flags;
> @@ -1013,11 +1013,13 @@ tvp514x_get_pdata(struct i2c_client *client)
>         if (!endpoint)
>                 return NULL;
>
> +       if (v4l2_of_parse_endpoint(endpoint, &bus_cfg))
> +               goto done;
> +
>         pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
>         if (!pdata)
>                 goto done;
>
> -       v4l2_of_parse_endpoint(endpoint, &bus_cfg);
>         flags = bus_cfg.bus.parallel.flags;
>
>         if (flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH)
> --
> 2.4.3
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 6/8] [media] tvp7002: Check v4l2_of_parse_endpoint() return value
  2016-01-11 16:47 ` [PATCH v2 6/8] [media] tvp7002: " Javier Martinez Canillas
@ 2016-01-13 10:40   ` Lad, Prabhakar
  0 siblings, 0 replies; 13+ messages in thread
From: Lad, Prabhakar @ 2016-01-13 10:40 UTC (permalink / raw)
  To: Javier Martinez Canillas
  Cc: LKML, Mauro Carvalho Chehab, Sakari Ailus,
	Ricardo Ribalda Delgado, Laurent Pinchart, Hans Verkuil,
	linux-media

On Mon, Jan 11, 2016 at 4:47 PM, Javier Martinez Canillas
<javier@osg.samsung.com> wrote:
> The v4l2_of_parse_endpoint() function can fail so check the return value.
>
> Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
>
Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>

Regards,
--Prabhakar Lad

> ---
>
> Changes in v2:
> - Assign pdata to NULL in case v4l2_of_parse_endpoint() fails before kzalloc.
>   Suggested by Sakari Ailus.
>
>  drivers/media/i2c/tvp7002.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/i2c/tvp7002.c b/drivers/media/i2c/tvp7002.c
> index 83c79fa5f61d..4df640c3aa40 100644
> --- a/drivers/media/i2c/tvp7002.c
> +++ b/drivers/media/i2c/tvp7002.c
> @@ -894,7 +894,7 @@ static struct tvp7002_config *
>  tvp7002_get_pdata(struct i2c_client *client)
>  {
>         struct v4l2_of_endpoint bus_cfg;
> -       struct tvp7002_config *pdata;
> +       struct tvp7002_config *pdata = NULL;
>         struct device_node *endpoint;
>         unsigned int flags;
>
> @@ -905,11 +905,13 @@ tvp7002_get_pdata(struct i2c_client *client)
>         if (!endpoint)
>                 return NULL;
>
> +       if (v4l2_of_parse_endpoint(endpoint, &bus_cfg))
> +               goto done;
> +
>         pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
>         if (!pdata)
>                 goto done;
>
> -       v4l2_of_parse_endpoint(endpoint, &bus_cfg);
>         flags = bus_cfg.bus.parallel.flags;
>
>         if (flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH)
> --
> 2.4.3
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2016-01-13 10:41 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-11 16:47 [PATCH v2 0/8] [media] Check v4l2_of_parse_endpoint() ret val in all drivers Javier Martinez Canillas
2016-01-11 16:47 ` Javier Martinez Canillas
2016-01-11 16:47 ` [PATCH v2 1/8] [media] v4l: of: Correct v4l2_of_parse_endpoint() kernel-doc Javier Martinez Canillas
2016-01-11 16:47 ` [PATCH v2 2/8] [media] adv7604: Check v4l2_of_parse_endpoint() return value Javier Martinez Canillas
2016-01-11 16:47 ` [PATCH v2 3/8] [media] s5c73m3: " Javier Martinez Canillas
2016-01-11 16:47 ` [PATCH v2 4/8] [media] s5k5baf: " Javier Martinez Canillas
2016-01-11 16:47 ` [PATCH v2 5/8] [media] tvp514x: " Javier Martinez Canillas
2016-01-13 10:39   ` Lad, Prabhakar
2016-01-11 16:47 ` [PATCH v2 6/8] [media] tvp7002: " Javier Martinez Canillas
2016-01-13 10:40   ` Lad, Prabhakar
2016-01-11 16:47 ` [PATCH v2 7/8] [media] exynos4-is: " Javier Martinez Canillas
2016-01-11 16:47   ` Javier Martinez Canillas
2016-01-11 16:47 ` [PATCH v2 8/8] [media] omap3isp: " Javier Martinez Canillas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.