Skip to contentSkip to conversation

exynos4-is: Add missing endpoint of_node_put on error paths

PATCH In review Krzysztof Kozlowski 3 participants 7 messages Jan 26, 2016 – Mar 13, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 exynos4-is: Add missing endpoint of_node_put on error paths

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")

---

Not tested on hardware, only built+static checkers.

---
 drivers/media/platform/exynos4-is/media-dev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/platform/exynos4-is/media-dev.c +3 -1
index f3b2dd30ec77..de0977479327 100644
@@ -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;
 
Signature · 1 line
1.9.1
#1 lore raw

PATCH 2/2 exynos4-is: Add missing port parent of_node_put on error paths

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")

---

Not tested on hardware, only built+static checkers.

---
 drivers/media/platform/exynos4-is/media-dev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/platform/exynos4-is/media-dev.c +3 -1
index de0977479327..d2e564878e06 100644
@@ -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;
Signature · 1 line
1.9.1
Reviewed-by on v1 2/2
#2 lore raw

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

Hello Krzysztof,

Quoted 20 lines · Krzysztof Kozlowski

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")

---

Not tested on hardware, only built+static checkers.

---
 drivers/media/platform/exynos4-is/media-dev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/platform/exynos4-is/media-dev.c +0 -0
index de0977479327..d2e564878e06 100644
@@ -385,8 +385,10 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
 	else

drivers/media/platform/exynos4-is/media-dev.c static int fimc_md_parse_port_node(struct fimc_md *fmd, · line 394

Quoted 10 lines
drivers/media/platform/exynos4-is/media-dev.c +3 -1
 		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;

Best regards,

Signature · 3 lines
Javier Martinez Canillas
Open Source Group
Samsung Research America
#3 lore raw

PATCH 2/2 exynos4-is: Add missing port parent of_node_put on error paths

In reply to Krzysztof Kozlowski
Quoted 6 lines · Krzysztof Kozlowski

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")

Thanks, patch applied with s/is get/is acquired/.

Quoted 24 lines

---

Not tested on hardware, only built+static checkers.

---
 drivers/media/platform/exynos4-is/media-dev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/platform/exynos4-is/media-dev.c +3 -1
index de0977479327..d2e564878e06 100644
@@ -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;
Signature · 2 lines
Regards,
Sylwester
Reviewed-by on v1 1/2
#4 lore raw
In reply to Krzysztof Kozlowski

Hello Krzysztof,

Quoted 20 lines · Krzysztof Kozlowski

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")

---

Not tested on hardware, only built+static checkers.

---
 drivers/media/platform/exynos4-is/media-dev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/platform/exynos4-is/media-dev.c +0 -0
index f3b2dd30ec77..de0977479327 100644
@@ -339,8 +339,10 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
 		return 0;

drivers/media/platform/exynos4-is/media-dev.c static int fimc_md_parse_port_node(struct fimc_md *fmd, · line 348

Quoted 10 lines
drivers/media/platform/exynos4-is/media-dev.c +3 -1
 
 	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;
 

Best regards,

Signature · 3 lines
Javier Martinez Canillas
Open Source Group
Samsung Research America
#5 lore raw

PATCH 1/2 exynos4-is: Add missing endpoint of_node_put on error paths

In reply to Krzysztof Kozlowski
Quoted 2 lines · Krzysztof Kozlowski

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 14 lines
Fixes 56fa1a6a6a7d ("[media] s5p-fimc: Change the driver directory name to exynos4-is")

---
Not tested on hardware, only built+static checkers.

---
 drivers/media/platform/exynos4-is/media-dev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/platform/exynos4-is/media-dev.c +0 -0
index f3b2dd30ec77..de0977479327 100644

drivers/media/platform/exynos4-is/media-dev.c static int fimc_md_parse_port_node(struct fimc_md *fmd, · line 345

Quoted 8 lines
drivers/media/platform/exynos4-is/media-dev.c +3 -1
@@ -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<----------------------------------

(quoted diff) +0 -0

b/drivers/media/platform/exynos4-is/media-dev.c
index feb521f..663d32e 100644

drivers/media/platform/exynos4-is/media-dev.c +11 -10
@@ -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<----------------------------------

Signature · 4 lines
Thanks,
Sylwester

[1] git://linuxtv.org/media_tree.git
#6 lore raw

PATCH 1/2 exynos4-is: Add missing endpoint of_node_put on error paths

Quoted 26 lines · Sylwester Nawrocki
Quoted 2 lines · Krzysztof Kozlowski

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 16 lines
Fixes 56fa1a6a6a7d ("[media] s5p-fimc: Change the driver directory name to exynos4-is")

---
Not tested on hardware, only built+static checkers.

---
 drivers/media/platform/exynos4-is/media-dev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/platform/exynos4-is/media-dev.c +0 -0
index f3b2dd30ec77..de0977479327 100644
@@ -339,8 +339,10 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
 		return 0;
 
Quoted 12 lines

drivers/media/platform/exynos4-is/media-dev.c static int fimc_md_parse_port_node(struct fimc_md *fmd, · line 345

Quoted 6 lines
drivers/media/platform/exynos4-is/media-dev.c +3 -1
 	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