[RFT 1/2] [media] exynos4-is: Add missing endpoint of_node_put on error paths

Subsystems: media input infrastructure (v4l/dvb), the rest

7 messages, 3 authors, 2016-03-13 · open the first message on its own page

[RFT 1/2] [media] exynos4-is: Add missing endpoint of_node_put on error paths

From: Krzysztof Kozlowski <hidden>
Date: 2016-01-26 00:42:02

In fimc_md_parse_port_node() endpoint node is get with of_get_next_child()
but it is not put on error path.

Fixes: 56fa1a6a6a7d ("[media] s5p-fimc: Change the driver directory name to exynos4-is")
Signed-off-by: Krzysztof Kozlowski <redacted>

---

Not tested on hardware, only built+static checkers.
---
 drivers/media/platform/exynos4-is/media-dev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
index f3b2dd30ec77..de0977479327 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -339,8 +339,10 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
 		return 0;
 
 	v4l2_of_parse_endpoint(ep, &endpoint);
-	if (WARN_ON(endpoint.base.port == 0) || index >= FIMC_MAX_SENSORS)
+	if (WARN_ON(endpoint.base.port == 0) || index >= FIMC_MAX_SENSORS) {
+		of_node_put(ep);
 		return -EINVAL;
+	}
 
 	pd->mux_id = (endpoint.base.port - 1) & 0x1;
 
-- 
1.9.1

[RFT 2/2] [media] exynos4-is: Add missing port parent of_node_put on error paths

From: Krzysztof Kozlowski <hidden>
Date: 2016-01-26 00:42:07

In fimc_md_parse_port_node() remote port parent node is get with
of_graph_get_remote_port_parent() but it is not put on error path.

Fixes: fa91f1056f17 ("[media] exynos4-is: Add support for asynchronous subdevices registration")
Signed-off-by: Krzysztof Kozlowski <redacted>

---

Not tested on hardware, only built+static checkers.
---
 drivers/media/platform/exynos4-is/media-dev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
index de0977479327..d2e564878e06 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -385,8 +385,10 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
 	else
 		pd->fimc_bus_type = pd->sensor_bus_type;
 
-	if (WARN_ON(index >= ARRAY_SIZE(fmd->sensor)))
+	if (WARN_ON(index >= ARRAY_SIZE(fmd->sensor))) {
+		of_node_put(rem);
 		return -EINVAL;
+	}
 
 	fmd->sensor[index].asd.match_type = V4L2_ASYNC_MATCH_OF;
 	fmd->sensor[index].asd.match.of.node = rem;
-- 
1.9.1

Re: [RFT 1/2] [media] exynos4-is: Add missing endpoint of_node_put on error paths

From: Javier Martinez Canillas <hidden>
Date: 2016-03-07 14:15:54

Hello Krzysztof,

On 01/25/2016 09:41 PM, Krzysztof Kozlowski wrote:
quoted hunk
In fimc_md_parse_port_node() endpoint node is get with of_get_next_child()
but it is not put on error path.

Fixes: 56fa1a6a6a7d ("[media] s5p-fimc: Change the driver directory name to exynos4-is")
Signed-off-by: Krzysztof Kozlowski <redacted>

---

Not tested on hardware, only built+static checkers.
---
 drivers/media/platform/exynos4-is/media-dev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
index f3b2dd30ec77..de0977479327 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -339,8 +339,10 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
 		return 0;
 
 	v4l2_of_parse_endpoint(ep, &endpoint);
-	if (WARN_ON(endpoint.base.port == 0) || index >= FIMC_MAX_SENSORS)
+	if (WARN_ON(endpoint.base.port == 0) || index >= FIMC_MAX_SENSORS) {
+		of_node_put(ep);
 		return -EINVAL;
+	}
 
 	pd->mux_id = (endpoint.base.port - 1) & 0x1;
 
Reviewed-by: Javier Martinez Canillas <redacted>

Best regards,
-- 
Javier Martinez Canillas
Open Source Group
Samsung Research America

Re: [RFT 2/2] [media] exynos4-is: Add missing port parent of_node_put on error paths

From: Javier Martinez Canillas <hidden>
Date: 2016-03-07 14:18:07

Hello Krzysztof,

On 01/25/2016 09:41 PM, Krzysztof Kozlowski wrote:
quoted hunk
In fimc_md_parse_port_node() remote port parent node is get with
of_graph_get_remote_port_parent() but it is not put on error path.

Fixes: fa91f1056f17 ("[media] exynos4-is: Add support for asynchronous subdevices registration")
Signed-off-by: Krzysztof Kozlowski <redacted>

---

Not tested on hardware, only built+static checkers.
---
 drivers/media/platform/exynos4-is/media-dev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
index de0977479327..d2e564878e06 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -385,8 +385,10 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
 	else
 		pd->fimc_bus_type = pd->sensor_bus_type;
 
-	if (WARN_ON(index >= ARRAY_SIZE(fmd->sensor)))
+	if (WARN_ON(index >= ARRAY_SIZE(fmd->sensor))) {
+		of_node_put(rem);
 		return -EINVAL;
+	}
 
 	fmd->sensor[index].asd.match_type = V4L2_ASYNC_MATCH_OF;
 	fmd->sensor[index].asd.match.of.node = rem;
Reviewed-by: Javier Martinez Canillas <redacted>

Best regards,
-- 
Javier Martinez Canillas
Open Source Group
Samsung Research America

Re: [RFT 1/2] [media] exynos4-is: Add missing endpoint of_node_put on error paths

From: Sylwester Nawrocki <s.nawrocki@samsung.com>
Date: 2016-03-11 12:31:03

On 01/26/2016 01:41 AM, Krzysztof Kozlowski wrote:
In fimc_md_parse_port_node() endpoint node is get with of_get_next_child()
but it is not put on error path.
"is get" doesn't sound right to me, how about rephrasing this to:

"In fimc_md_parse_port_node() reference count of the endpoint node
"is incremented by of_get_next_child() but it is not decremented
 on error path."
quoted hunk
Fixes: 56fa1a6a6a7d ("[media] s5p-fimc: Change the driver directory name to exynos4-is")
Signed-off-by: Krzysztof Kozlowski <redacted>
---
Not tested on hardware, only built+static checkers.
---
 drivers/media/platform/exynos4-is/media-dev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/exynos4-is/media-dev.c 
b/drivers/media/platform/exynos4-is/media-dev.c
index f3b2dd30ec77..de0977479327 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -339,8 +339,10 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
 		return 0;
 
 	v4l2_of_parse_endpoint(ep, &endpoint);
-	if (WARN_ON(endpoint.base.port == 0) || index >= FIMC_MAX_SENSORS)
+	if (WARN_ON(endpoint.base.port == 0) || index >= FIMC_MAX_SENSORS) {
+		of_node_put(ep);
 		return -EINVAL;
+	}
Thanks for the patch, it looks correct but it doesn't apply cleanly
due to patches already in media master branch [1]. Could you refresh
this patch and resend?
Also I don't quite like multiple calls to of_node_put(), how about
doing something like this instead:

---------------------------8<----------------------------------
diff --git a/drivers/media/platform/exynos4-is/media-dev.c
b/drivers/media/platform/exynos4-is/media-dev.c
index feb521f..663d32e 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -397,18 +397,19 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
                return 0;

        ret = v4l2_of_parse_endpoint(ep, &endpoint);
-       if (ret) {
-               of_node_put(ep);
-               return ret;
+       if (!ret) {
+               if (WARN_ON(endpoint.base.port == 0) ||
+                           index >= FIMC_MAX_SENSORS) {
+                       ret = -EINVAL;
+               } else {
+                       pd->mux_id = (endpoint.base.port - 1) & 0x1;
+                       rem = of_graph_get_remote_port_parent(ep);
+               }
        }
-
-       if (WARN_ON(endpoint.base.port == 0) || index >= FIMC_MAX_SENSORS)
-               return -EINVAL;
-
-       pd->mux_id = (endpoint.base.port - 1) & 0x1;
-
-       rem = of_graph_get_remote_port_parent(ep);
        of_node_put(ep);
+       if (ret < 0)
+               return ret;
+
        if (rem == NULL) {
                v4l2_info(&fmd->v4l2_dev, "Remote device at %s not found\n",
                                                        ep->full_name);
---------------------------8<----------------------------------
-- 
Thanks,
Sylwester

[1] git://linuxtv.org/media_tree.git

Re: [RFT 2/2] [media] exynos4-is: Add missing port parent of_node_put on error paths

From: Sylwester Nawrocki <s.nawrocki@samsung.com>
Date: 2016-03-11 12:38:00

On 01/26/2016 01:41 AM, Krzysztof Kozlowski wrote:
In fimc_md_parse_port_node() remote port parent node is get with
of_graph_get_remote_port_parent() but it is not put on error path.

Fixes: fa91f1056f17 ("[media] exynos4-is: Add support for 
asynchronous subdevices registration")
Signed-off-by: Krzysztof Kozlowski <redacted>
Thanks, patch applied with s/is get/is acquired/.
quoted hunk
---

Not tested on hardware, only built+static checkers.
---
 drivers/media/platform/exynos4-is/media-dev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/exynos4-is/media-dev.c 
b/drivers/media/platform/exynos4-is/media-dev.c
index de0977479327..d2e564878e06 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -385,8 +385,10 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
 	else
 		pd->fimc_bus_type = pd->sensor_bus_type;
 
-	if (WARN_ON(index >= ARRAY_SIZE(fmd->sensor)))
+	if (WARN_ON(index >= ARRAY_SIZE(fmd->sensor))) {
+		of_node_put(rem);
 		return -EINVAL;
+	}
 
 	fmd->sensor[index].asd.match_type = V4L2_ASYNC_MATCH_OF;
 	fmd->sensor[index].asd.match.of.node = rem;
-- 
Regards,
Sylwester

Re: [RFT 1/2] [media] exynos4-is: Add missing endpoint of_node_put on error paths

From: Krzysztof Kozlowski <hidden>
Date: 2016-03-13 23:51:10

On 11.03.2016 21:30, Sylwester Nawrocki wrote:
On 01/26/2016 01:41 AM, Krzysztof Kozlowski wrote:
quoted
In fimc_md_parse_port_node() endpoint node is get with of_get_next_child()
but it is not put on error path.
"is get" doesn't sound right to me, how about rephrasing this to:

"In fimc_md_parse_port_node() reference count of the endpoint node
"is incremented by of_get_next_child() but it is not decremented
 on error path."
quoted
Fixes: 56fa1a6a6a7d ("[media] s5p-fimc: Change the driver directory name to exynos4-is")
Signed-off-by: Krzysztof Kozlowski <redacted>
---
Not tested on hardware, only built+static checkers.
---
 drivers/media/platform/exynos4-is/media-dev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/exynos4-is/media-dev.c 
b/drivers/media/platform/exynos4-is/media-dev.c
index f3b2dd30ec77..de0977479327 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -339,8 +339,10 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
 		return 0;
 
 	v4l2_of_parse_endpoint(ep, &endpoint);
-	if (WARN_ON(endpoint.base.port == 0) || index >= FIMC_MAX_SENSORS)
+	if (WARN_ON(endpoint.base.port == 0) || index >= FIMC_MAX_SENSORS) {
+		of_node_put(ep);
 		return -EINVAL;
+	}
Thanks for the patch, it looks correct but it doesn't apply cleanly
due to patches already in media master branch [1]. Could you refresh
this patch and resend?
Also I don't quite like multiple calls to of_node_put(), how about
doing something like this instead:
How about sending your patch then with my reported-by?

Best regards,
Krzysztof
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help