* [PATCH 1/2] media: stm32-dcmi: drop unnecessary while(1) loop
@ 2018-06-12 17:22 ` Nicholas Mc Guire
0 siblings, 0 replies; 10+ messages in thread
From: Nicholas Mc Guire @ 2018-06-12 17:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: Maxime Coquelin, Alexandre Torgue, Hans Verkuil, Hugues Fruchet,
Philipp Zabel, Niklas Soderlund, Benjamin Gaignard,
Gustavo A. R. Silva, linux-media, linux-arm-kernel, linux-kernel,
Nicholas Mc Guire
The while(1) is effectively useless as all possible paths within it
return thus there is no way to loop.
Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
---
This is not actually fixing any bug - the while(1){ } will not hurt here
it is though simply unnecessary. Found during code review.
The diff output is not very readable - essentially only the outer
while(1){ } was removed.
Patch was compile tested with: x86_64_defconfig, MEDIA_SUPPORT=y
MEDIA_CAMERA_SUPPORT=y, V4L_PLATFORM_DRIVERS=y, OF=y, COMPILE_TEST=y
CONFIG_VIDEO_STM32_DCMI=y
(There are a number of sparse warnings - not related to the changes though)
Patch is against 4.17.0 (localversion-next is next-20180608)
drivers/media/platform/stm32/stm32-dcmi.c | 28 +++++++++++++---------------
1 file changed, 13 insertions(+), 15 deletions(-)
diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c
index 2e1933d..70b81d2 100644
--- a/drivers/media/platform/stm32/stm32-dcmi.c
+++ b/drivers/media/platform/stm32/stm32-dcmi.c
@@ -1605,23 +1605,21 @@ static int dcmi_graph_parse(struct stm32_dcmi *dcmi, struct device_node *node)
struct device_node *ep = NULL;
struct device_node *remote;
- while (1) {
- ep = of_graph_get_next_endpoint(node, ep);
- if (!ep)
- return -EINVAL;
-
- remote = of_graph_get_remote_port_parent(ep);
- if (!remote) {
- of_node_put(ep);
- return -EINVAL;
- }
+ ep = of_graph_get_next_endpoint(node, ep);
+ if (!ep)
+ return -EINVAL;
- /* Remote node to connect */
- dcmi->entity.node = remote;
- dcmi->entity.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
- dcmi->entity.asd.match.fwnode = of_fwnode_handle(remote);
- return 0;
+ remote = of_graph_get_remote_port_parent(ep);
+ if (!remote) {
+ of_node_put(ep);
+ return -EINVAL;
}
+
+ /* Remote node to connect */
+ dcmi->entity.node = remote;
+ dcmi->entity.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
+ dcmi->entity.asd.match.fwnode = of_fwnode_handle(remote);
+ return 0;
}
static int dcmi_graph_init(struct stm32_dcmi *dcmi)
--
2.1.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 1/2] media: stm32-dcmi: drop unnecessary while(1) loop
@ 2018-06-12 17:22 ` Nicholas Mc Guire
0 siblings, 0 replies; 10+ messages in thread
From: Nicholas Mc Guire @ 2018-06-12 17:22 UTC (permalink / raw)
To: linux-arm-kernel
The while(1) is effectively useless as all possible paths within it
return thus there is no way to loop.
Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
---
This is not actually fixing any bug - the while(1){ } will not hurt here
it is though simply unnecessary. Found during code review.
The diff output is not very readable - essentially only the outer
while(1){ } was removed.
Patch was compile tested with: x86_64_defconfig, MEDIA_SUPPORT=y
MEDIA_CAMERA_SUPPORT=y, V4L_PLATFORM_DRIVERS=y, OF=y, COMPILE_TEST=y
CONFIG_VIDEO_STM32_DCMI=y
(There are a number of sparse warnings - not related to the changes though)
Patch is against 4.17.0 (localversion-next is next-20180608)
drivers/media/platform/stm32/stm32-dcmi.c | 28 +++++++++++++---------------
1 file changed, 13 insertions(+), 15 deletions(-)
diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c
index 2e1933d..70b81d2 100644
--- a/drivers/media/platform/stm32/stm32-dcmi.c
+++ b/drivers/media/platform/stm32/stm32-dcmi.c
@@ -1605,23 +1605,21 @@ static int dcmi_graph_parse(struct stm32_dcmi *dcmi, struct device_node *node)
struct device_node *ep = NULL;
struct device_node *remote;
- while (1) {
- ep = of_graph_get_next_endpoint(node, ep);
- if (!ep)
- return -EINVAL;
-
- remote = of_graph_get_remote_port_parent(ep);
- if (!remote) {
- of_node_put(ep);
- return -EINVAL;
- }
+ ep = of_graph_get_next_endpoint(node, ep);
+ if (!ep)
+ return -EINVAL;
- /* Remote node to connect */
- dcmi->entity.node = remote;
- dcmi->entity.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
- dcmi->entity.asd.match.fwnode = of_fwnode_handle(remote);
- return 0;
+ remote = of_graph_get_remote_port_parent(ep);
+ if (!remote) {
+ of_node_put(ep);
+ return -EINVAL;
}
+
+ /* Remote node to connect */
+ dcmi->entity.node = remote;
+ dcmi->entity.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
+ dcmi->entity.asd.match.fwnode = of_fwnode_handle(remote);
+ return 0;
}
static int dcmi_graph_init(struct stm32_dcmi *dcmi)
--
2.1.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/2] media: stm32-dcmi: add mandatory of_node_put() in success path
2018-06-12 17:22 ` Nicholas Mc Guire
@ 2018-06-12 17:22 ` Nicholas Mc Guire
-1 siblings, 0 replies; 10+ messages in thread
From: Nicholas Mc Guire @ 2018-06-12 17:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: Maxime Coquelin, Alexandre Torgue, Hans Verkuil, Hugues Fruchet,
Philipp Zabel, Niklas Soderlund, Benjamin Gaignard,
Gustavo A. R. Silva, linux-media, linux-arm-kernel, linux-kernel,
Nicholas Mc Guire
The endpoint allocated by of_graph_get_next_endpoint() needs an of_node_put()
in both error and success path. As ep is not used the refcount decrement
can be right after the last use of ep.
Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Fixes: commit 37404f91ef8b ("[media] stm32-dcmi: STM32 DCMI camera interface driver")
---
Problem located with an experimental coccinelle script
Patch was compile tested with: x86_64_defconfig, MEDIA_SUPPORT=y
MEDIA_CAMERA_SUPPORT=y, V4L_PLATFORM_DRIVERS=y, OF=y, COMPILE_TEST=y
CONFIG_VIDEO_STM32_DCMI=y
(There are a number of sparse warnings - not related to the changes though)
Patch is on top of "[PATCH 1/2] media: stm32-dcmi: drop unneceeary while(1)
loop" against 4.17.0 (localversion-next is next-20180608)
drivers/media/platform/stm32/stm32-dcmi.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c
index 70b81d2..542d148 100644
--- a/drivers/media/platform/stm32/stm32-dcmi.c
+++ b/drivers/media/platform/stm32/stm32-dcmi.c
@@ -1610,10 +1610,9 @@ static int dcmi_graph_parse(struct stm32_dcmi *dcmi, struct device_node *node)
return -EINVAL;
remote = of_graph_get_remote_port_parent(ep);
- if (!remote) {
- of_node_put(ep);
+ of_node_put(ep);
+ if (!remote)
return -EINVAL;
- }
/* Remote node to connect */
dcmi->entity.node = remote;
--
2.1.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/2] media: stm32-dcmi: add mandatory of_node_put() in success path
@ 2018-06-12 17:22 ` Nicholas Mc Guire
0 siblings, 0 replies; 10+ messages in thread
From: Nicholas Mc Guire @ 2018-06-12 17:22 UTC (permalink / raw)
To: linux-arm-kernel
The endpoint allocated by of_graph_get_next_endpoint() needs an of_node_put()
in both error and success path. As ep is not used the refcount decrement
can be right after the last use of ep.
Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Fixes: commit 37404f91ef8b ("[media] stm32-dcmi: STM32 DCMI camera interface driver")
---
Problem located with an experimental coccinelle script
Patch was compile tested with: x86_64_defconfig, MEDIA_SUPPORT=y
MEDIA_CAMERA_SUPPORT=y, V4L_PLATFORM_DRIVERS=y, OF=y, COMPILE_TEST=y
CONFIG_VIDEO_STM32_DCMI=y
(There are a number of sparse warnings - not related to the changes though)
Patch is on top of "[PATCH 1/2] media: stm32-dcmi: drop unneceeary while(1)
loop" against 4.17.0 (localversion-next is next-20180608)
drivers/media/platform/stm32/stm32-dcmi.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c
index 70b81d2..542d148 100644
--- a/drivers/media/platform/stm32/stm32-dcmi.c
+++ b/drivers/media/platform/stm32/stm32-dcmi.c
@@ -1610,10 +1610,9 @@ static int dcmi_graph_parse(struct stm32_dcmi *dcmi, struct device_node *node)
return -EINVAL;
remote = of_graph_get_remote_port_parent(ep);
- if (!remote) {
- of_node_put(ep);
+ of_node_put(ep);
+ if (!remote)
return -EINVAL;
- }
/* Remote node to connect */
dcmi->entity.node = remote;
--
2.1.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] media: stm32-dcmi: drop unnecessary while(1) loop
2018-06-12 17:22 ` Nicholas Mc Guire
(?)
@ 2018-06-18 9:34 ` Hugues FRUCHET
-1 siblings, 0 replies; 10+ messages in thread
From: Hugues FRUCHET @ 2018-06-18 9:34 UTC (permalink / raw)
To: Nicholas Mc Guire, Mauro Carvalho Chehab
Cc: Maxime Coquelin, Alexandre TORGUE, Hans Verkuil, Philipp Zabel,
Niklas Soderlund, Benjamin Gaignard, Gustavo A. R. Silva,
linux-media, linux-arm-kernel, linux-kernel
Hi Nicholas,
thanks for patch !
On 06/12/2018 07:22 PM, Nicholas Mc Guire wrote:
> The while(1) is effectively useless as all possible paths within it
> return thus there is no way to loop.
>
> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Acked-by: Hugues Fruchet <hugues.fruchet@st.com>
> ---
>
> This is not actually fixing any bug - the while(1){ } will not hurt here
> it is though simply unnecessary. Found during code review.
>
> The diff output is not very readable - essentially only the outer
> while(1){ } was removed.
>
> Patch was compile tested with: x86_64_defconfig, MEDIA_SUPPORT=y
> MEDIA_CAMERA_SUPPORT=y, V4L_PLATFORM_DRIVERS=y, OF=y, COMPILE_TEST=y
> CONFIG_VIDEO_STM32_DCMI=y
> (There are a number of sparse warnings - not related to the changes though)
>
> Patch is against 4.17.0 (localversion-next is next-20180608)
>
> drivers/media/platform/stm32/stm32-dcmi.c | 28 +++++++++++++---------------
> 1 file changed, 13 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c
> index 2e1933d..70b81d2 100644
> --- a/drivers/media/platform/stm32/stm32-dcmi.c
> +++ b/drivers/media/platform/stm32/stm32-dcmi.c
> @@ -1605,23 +1605,21 @@ static int dcmi_graph_parse(struct stm32_dcmi *dcmi, struct device_node *node)
> struct device_node *ep = NULL;
> struct device_node *remote;
>
> - while (1) {
> - ep = of_graph_get_next_endpoint(node, ep);
> - if (!ep)
> - return -EINVAL;
> -
> - remote = of_graph_get_remote_port_parent(ep);
> - if (!remote) {
> - of_node_put(ep);
> - return -EINVAL;
> - }
> + ep = of_graph_get_next_endpoint(node, ep);
> + if (!ep)
> + return -EINVAL;
>
> - /* Remote node to connect */
> - dcmi->entity.node = remote;
> - dcmi->entity.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> - dcmi->entity.asd.match.fwnode = of_fwnode_handle(remote);
> - return 0;
> + remote = of_graph_get_remote_port_parent(ep);
> + if (!remote) {
> + of_node_put(ep);
> + return -EINVAL;
> }
> +
> + /* Remote node to connect */
> + dcmi->entity.node = remote;
> + dcmi->entity.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> + dcmi->entity.asd.match.fwnode = of_fwnode_handle(remote);
> + return 0;
> }
>
> static int dcmi_graph_init(struct stm32_dcmi *dcmi)
>
BR,
Hugues.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] media: stm32-dcmi: drop unnecessary while(1) loop
@ 2018-06-18 9:34 ` Hugues FRUCHET
0 siblings, 0 replies; 10+ messages in thread
From: Hugues FRUCHET @ 2018-06-18 9:34 UTC (permalink / raw)
To: Nicholas Mc Guire, Mauro Carvalho Chehab
Cc: Maxime Coquelin, Alexandre TORGUE, Hans Verkuil, Philipp Zabel,
Niklas Soderlund, Benjamin Gaignard, Gustavo A. R. Silva,
linux-media, linux-arm-kernel, linux-kernel
Hi Nicholas,
thanks for patch !
On 06/12/2018 07:22 PM, Nicholas Mc Guire wrote:
> The while(1) is effectively useless as all possible paths within it
> return thus there is no way to loop.
>
> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Acked-by: Hugues Fruchet <hugues.fruchet@st.com>
> ---
>
> This is not actually fixing any bug - the while(1){ } will not hurt here
> it is though simply unnecessary. Found during code review.
>
> The diff output is not very readable - essentially only the outer
> while(1){ } was removed.
>
> Patch was compile tested with: x86_64_defconfig, MEDIA_SUPPORT=y
> MEDIA_CAMERA_SUPPORT=y, V4L_PLATFORM_DRIVERS=y, OF=y, COMPILE_TEST=y
> CONFIG_VIDEO_STM32_DCMI=y
> (There are a number of sparse warnings - not related to the changes though)
>
> Patch is against 4.17.0 (localversion-next is next-20180608)
>
> drivers/media/platform/stm32/stm32-dcmi.c | 28 +++++++++++++---------------
> 1 file changed, 13 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c
> index 2e1933d..70b81d2 100644
> --- a/drivers/media/platform/stm32/stm32-dcmi.c
> +++ b/drivers/media/platform/stm32/stm32-dcmi.c
> @@ -1605,23 +1605,21 @@ static int dcmi_graph_parse(struct stm32_dcmi *dcmi, struct device_node *node)
> struct device_node *ep = NULL;
> struct device_node *remote;
>
> - while (1) {
> - ep = of_graph_get_next_endpoint(node, ep);
> - if (!ep)
> - return -EINVAL;
> -
> - remote = of_graph_get_remote_port_parent(ep);
> - if (!remote) {
> - of_node_put(ep);
> - return -EINVAL;
> - }
> + ep = of_graph_get_next_endpoint(node, ep);
> + if (!ep)
> + return -EINVAL;
>
> - /* Remote node to connect */
> - dcmi->entity.node = remote;
> - dcmi->entity.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> - dcmi->entity.asd.match.fwnode = of_fwnode_handle(remote);
> - return 0;
> + remote = of_graph_get_remote_port_parent(ep);
> + if (!remote) {
> + of_node_put(ep);
> + return -EINVAL;
> }
> +
> + /* Remote node to connect */
> + dcmi->entity.node = remote;
> + dcmi->entity.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> + dcmi->entity.asd.match.fwnode = of_fwnode_handle(remote);
> + return 0;
> }
>
> static int dcmi_graph_init(struct stm32_dcmi *dcmi)
>
BR,
Hugues.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/2] media: stm32-dcmi: drop unnecessary while(1) loop
@ 2018-06-18 9:34 ` Hugues FRUCHET
0 siblings, 0 replies; 10+ messages in thread
From: Hugues FRUCHET @ 2018-06-18 9:34 UTC (permalink / raw)
To: linux-arm-kernel
Hi Nicholas,
thanks for patch !
On 06/12/2018 07:22 PM, Nicholas Mc Guire wrote:
> The while(1) is effectively useless as all possible paths within it
> return thus there is no way to loop.
>
> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Acked-by: Hugues Fruchet <hugues.fruchet@st.com>
> ---
>
> This is not actually fixing any bug - the while(1){ } will not hurt here
> it is though simply unnecessary. Found during code review.
>
> The diff output is not very readable - essentially only the outer
> while(1){ } was removed.
>
> Patch was compile tested with: x86_64_defconfig, MEDIA_SUPPORT=y
> MEDIA_CAMERA_SUPPORT=y, V4L_PLATFORM_DRIVERS=y, OF=y, COMPILE_TEST=y
> CONFIG_VIDEO_STM32_DCMI=y
> (There are a number of sparse warnings - not related to the changes though)
>
> Patch is against 4.17.0 (localversion-next is next-20180608)
>
> drivers/media/platform/stm32/stm32-dcmi.c | 28 +++++++++++++---------------
> 1 file changed, 13 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c
> index 2e1933d..70b81d2 100644
> --- a/drivers/media/platform/stm32/stm32-dcmi.c
> +++ b/drivers/media/platform/stm32/stm32-dcmi.c
> @@ -1605,23 +1605,21 @@ static int dcmi_graph_parse(struct stm32_dcmi *dcmi, struct device_node *node)
> struct device_node *ep = NULL;
> struct device_node *remote;
>
> - while (1) {
> - ep = of_graph_get_next_endpoint(node, ep);
> - if (!ep)
> - return -EINVAL;
> -
> - remote = of_graph_get_remote_port_parent(ep);
> - if (!remote) {
> - of_node_put(ep);
> - return -EINVAL;
> - }
> + ep = of_graph_get_next_endpoint(node, ep);
> + if (!ep)
> + return -EINVAL;
>
> - /* Remote node to connect */
> - dcmi->entity.node = remote;
> - dcmi->entity.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> - dcmi->entity.asd.match.fwnode = of_fwnode_handle(remote);
> - return 0;
> + remote = of_graph_get_remote_port_parent(ep);
> + if (!remote) {
> + of_node_put(ep);
> + return -EINVAL;
> }
> +
> + /* Remote node to connect */
> + dcmi->entity.node = remote;
> + dcmi->entity.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> + dcmi->entity.asd.match.fwnode = of_fwnode_handle(remote);
> + return 0;
> }
>
> static int dcmi_graph_init(struct stm32_dcmi *dcmi)
>
BR,
Hugues.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] media: stm32-dcmi: add mandatory of_node_put() in success path
2018-06-12 17:22 ` Nicholas Mc Guire
(?)
@ 2018-06-18 9:49 ` Hugues FRUCHET
-1 siblings, 0 replies; 10+ messages in thread
From: Hugues FRUCHET @ 2018-06-18 9:49 UTC (permalink / raw)
To: Nicholas Mc Guire, Mauro Carvalho Chehab
Cc: Maxime Coquelin, Alexandre TORGUE, Hans Verkuil, Philipp Zabel,
Niklas Soderlund, Benjamin Gaignard, Gustavo A. R. Silva,
linux-media, linux-arm-kernel, linux-kernel
Hi Nicholas,
Thanks for patch.
BR,
Hugues.
On 06/12/2018 07:22 PM, Nicholas Mc Guire wrote:
> The endpoint allocated by of_graph_get_next_endpoint() needs an of_node_put()
> in both error and success path. As ep is not used the refcount decrement
> can be right after the last use of ep.
>
> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Acked-by: Hugues Fruchet <hugues.fruchet@st.com>
> Fixes: commit 37404f91ef8b ("[media] stm32-dcmi: STM32 DCMI camera interface driver")
> ---
>
> Problem located with an experimental coccinelle script
>
> Patch was compile tested with: x86_64_defconfig, MEDIA_SUPPORT=y
> MEDIA_CAMERA_SUPPORT=y, V4L_PLATFORM_DRIVERS=y, OF=y, COMPILE_TEST=y
> CONFIG_VIDEO_STM32_DCMI=y
> (There are a number of sparse warnings - not related to the changes though)
>
> Patch is on top of "[PATCH 1/2] media: stm32-dcmi: drop unneceeary while(1)
> loop" against 4.17.0 (localversion-next is next-20180608)
>
> drivers/media/platform/stm32/stm32-dcmi.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c
> index 70b81d2..542d148 100644
> --- a/drivers/media/platform/stm32/stm32-dcmi.c
> +++ b/drivers/media/platform/stm32/stm32-dcmi.c
> @@ -1610,10 +1610,9 @@ static int dcmi_graph_parse(struct stm32_dcmi *dcmi, struct device_node *node)
> return -EINVAL;
>
> remote = of_graph_get_remote_port_parent(ep);
> - if (!remote) {
> - of_node_put(ep);
> + of_node_put(ep);
> + if (!remote)
> return -EINVAL;
> - }
>
> /* Remote node to connect */
> dcmi->entity.node = remote;
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] media: stm32-dcmi: add mandatory of_node_put() in success path
@ 2018-06-18 9:49 ` Hugues FRUCHET
0 siblings, 0 replies; 10+ messages in thread
From: Hugues FRUCHET @ 2018-06-18 9:49 UTC (permalink / raw)
To: Nicholas Mc Guire, Mauro Carvalho Chehab
Cc: Maxime Coquelin, Alexandre TORGUE, Hans Verkuil, Philipp Zabel,
Niklas Soderlund, Benjamin Gaignard, Gustavo A. R. Silva,
linux-media, linux-arm-kernel, linux-kernel
Hi Nicholas,
Thanks for patch.
BR,
Hugues.
On 06/12/2018 07:22 PM, Nicholas Mc Guire wrote:
> The endpoint allocated by of_graph_get_next_endpoint() needs an of_node_put()
> in both error and success path. As ep is not used the refcount decrement
> can be right after the last use of ep.
>
> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Acked-by: Hugues Fruchet <hugues.fruchet@st.com>
> Fixes: commit 37404f91ef8b ("[media] stm32-dcmi: STM32 DCMI camera interface driver")
> ---
>
> Problem located with an experimental coccinelle script
>
> Patch was compile tested with: x86_64_defconfig, MEDIA_SUPPORT=y
> MEDIA_CAMERA_SUPPORT=y, V4L_PLATFORM_DRIVERS=y, OF=y, COMPILE_TEST=y
> CONFIG_VIDEO_STM32_DCMI=y
> (There are a number of sparse warnings - not related to the changes though)
>
> Patch is on top of "[PATCH 1/2] media: stm32-dcmi: drop unneceeary while(1)
> loop" against 4.17.0 (localversion-next is next-20180608)
>
> drivers/media/platform/stm32/stm32-dcmi.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c
> index 70b81d2..542d148 100644
> --- a/drivers/media/platform/stm32/stm32-dcmi.c
> +++ b/drivers/media/platform/stm32/stm32-dcmi.c
> @@ -1610,10 +1610,9 @@ static int dcmi_graph_parse(struct stm32_dcmi *dcmi, struct device_node *node)
> return -EINVAL;
>
> remote = of_graph_get_remote_port_parent(ep);
> - if (!remote) {
> - of_node_put(ep);
> + of_node_put(ep);
> + if (!remote)
> return -EINVAL;
> - }
>
> /* Remote node to connect */
> dcmi->entity.node = remote;
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/2] media: stm32-dcmi: add mandatory of_node_put() in success path
@ 2018-06-18 9:49 ` Hugues FRUCHET
0 siblings, 0 replies; 10+ messages in thread
From: Hugues FRUCHET @ 2018-06-18 9:49 UTC (permalink / raw)
To: linux-arm-kernel
Hi Nicholas,
Thanks for patch.
BR,
Hugues.
On 06/12/2018 07:22 PM, Nicholas Mc Guire wrote:
> The endpoint allocated by of_graph_get_next_endpoint() needs an of_node_put()
> in both error and success path. As ep is not used the refcount decrement
> can be right after the last use of ep.
>
> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Acked-by: Hugues Fruchet <hugues.fruchet@st.com>
> Fixes: commit 37404f91ef8b ("[media] stm32-dcmi: STM32 DCMI camera interface driver")
> ---
>
> Problem located with an experimental coccinelle script
>
> Patch was compile tested with: x86_64_defconfig, MEDIA_SUPPORT=y
> MEDIA_CAMERA_SUPPORT=y, V4L_PLATFORM_DRIVERS=y, OF=y, COMPILE_TEST=y
> CONFIG_VIDEO_STM32_DCMI=y
> (There are a number of sparse warnings - not related to the changes though)
>
> Patch is on top of "[PATCH 1/2] media: stm32-dcmi: drop unneceeary while(1)
> loop" against 4.17.0 (localversion-next is next-20180608)
>
> drivers/media/platform/stm32/stm32-dcmi.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c
> index 70b81d2..542d148 100644
> --- a/drivers/media/platform/stm32/stm32-dcmi.c
> +++ b/drivers/media/platform/stm32/stm32-dcmi.c
> @@ -1610,10 +1610,9 @@ static int dcmi_graph_parse(struct stm32_dcmi *dcmi, struct device_node *node)
> return -EINVAL;
>
> remote = of_graph_get_remote_port_parent(ep);
> - if (!remote) {
> - of_node_put(ep);
> + of_node_put(ep);
> + if (!remote)
> return -EINVAL;
> - }
>
> /* Remote node to connect */
> dcmi->entity.node = remote;
>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2018-06-18 9:50 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-12 17:22 [PATCH 1/2] media: stm32-dcmi: drop unnecessary while(1) loop Nicholas Mc Guire
2018-06-12 17:22 ` Nicholas Mc Guire
2018-06-12 17:22 ` [PATCH 2/2] media: stm32-dcmi: add mandatory of_node_put() in success path Nicholas Mc Guire
2018-06-12 17:22 ` Nicholas Mc Guire
2018-06-18 9:49 ` Hugues FRUCHET
2018-06-18 9:49 ` Hugues FRUCHET
2018-06-18 9:49 ` Hugues FRUCHET
2018-06-18 9:34 ` [PATCH 1/2] media: stm32-dcmi: drop unnecessary while(1) loop Hugues FRUCHET
2018-06-18 9:34 ` Hugues FRUCHET
2018-06-18 9:34 ` Hugues FRUCHET
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.