media: platform: exynos4-is: media-dev: Add missing of_node_put
Subsystems (2)
PATCH 1/1 media: platform: exynos4-is: media-dev: Add missing of_node_put
for_each_available_child_of_node and for_each_child_of_node perform an of_node_get on each iteration, so to break out of the loop an of_node_put is required.
Found using Coccinelle. The simplified version of the semantic patch that is used for this is as follows:
// <smpl>
@@
local idexpression n;
expression e,r;
@@
for_each_available_child_of_node(r,n) {
...
(
of_node_put(n);
|
e = n
|
+ of_node_put(n);
? break;
)
...
}
... when != n
// </smpl>
--- drivers/media/platform/exynos4-is/media-dev.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/media/platform/exynos4-is/media-dev.c +9 -3
@@ -430,8 +430,10 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd)continue ; ret =fimc_md_parse_port_node (fmd, port, index); -if (ret <0 ) +if (ret <0 ) { +of_node_put (node); goto rpm_put; + } index++; }
@@ -442,8 +444,10 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd)for_each_child_of_node (ports, node) { ret =fimc_md_parse_port_node (fmd, node, index); -if (ret <0 ) +if (ret <0 ) { +of_node_put (node);break ; + } index++; } rpm_put:
@@ -651,8 +655,10 @@ static int fimc_md_register_platform_entities(struct fimc_md *fmd, ret =fimc_md_register_platform_entity (fmd, pdev, plat_entity);put_device (&pdev->dev); -if (ret <0 ) +if (ret <0 ) { +of_node_put (node);break ; + } }return ret;
Signature · 1 line
1.9.1
Quoted 15 lines · Amitoj Kaur Chawla
for_each_available_child_of_nodeandfor_each_child_of_nodeperform anof_node_geton each iteration, so to break out of the loop anof_node_putis required.Found using Coccinelle. The simplified version of the semantic patch that is used for this is as follows:
// <smpl>
@@
local idexpression n;
expression e,r;
@@for_each_available_child_of_node(r,n) { ...
Quoted 12 lines
(
of_node_put(n);
|
e = n
|
+of_node_put(n);
? break;
)
...
}
... when != n
// </smpl>
Patch iselft looks correct but why are you pasting coccinelle script into the message?
The script is already present in Linux kernel:scripts/coccinelle/iterators/device_node_continue.cocci
This just extends the commit message without any meaningful data so with removal of coccinelle script above:
Best regards,
Krzysztof
Quoted 47 lines
Signed-off-by Amitoj Kaur Chawla <[email protected]>--- drivers/media/platform/exynos4-is/media-dev.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)drivers/media/platform/exynos4-is/media-dev.c +9
-3@@ -430,8 +430,10 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd)continue ; ret =fimc_md_parse_port_node (fmd, port, index); -if (ret <0 ) +if (ret <0 ) { +of_node_put (node); goto rpm_put; + } index++; }@@ -442,8 +444,10 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd)for_each_child_of_node (ports, node) { ret =fimc_md_parse_port_node (fmd, node, index); -if (ret <0 ) +if (ret <0 ) { +of_node_put (node);break ; + } index++; } rpm_put:@@ -651,8 +655,10 @@ static int fimc_md_register_platform_entities(struct fimc_md *fmd, ret =fimc_md_register_platform_entity (fmd, pdev, plat_entity);put_device (&pdev->dev); -if (ret <0 ) +if (ret <0 ) { +of_node_put (node);break ; + } }return ret;
Quoted 29 lines · Krzysztof Kozlowski
Quoted 15 lines · Amitoj Kaur Chawla
for_each_available_child_of_nodeandfor_each_child_of_nodeperform anof_node_geton each iteration, so to break out of the loop anof_node_putis required.Found using Coccinelle. The simplified version of the semantic patch that is used for this is as follows:
// <smpl>
@@
local idexpression n;
expression e,r;
@@for_each_available_child_of_node(r,n) { ...Quoted 12 lines
(
of_node_put(n);
|
e = n
|
+of_node_put(n);
? break;
)
...
}
... when != n
// </smpl>
Quoted 5 lines
Patch iselft looks correct but why are you pasting coccinelle script into the message?
The script is already present in Linux kernel:
scripts/coccinelle/iterators/device_node_continue.cocci
I don't think so. The continue one takes care of the case where there is an extraneous of_node_put before a continue, not a missing one before a break. But OK to drop it if it doesn't seem useful.
julia
Quoted 56 lines
This just extends the commit message without any meaningful data so with removal of coccinelle script above:
Reviewed-by Krzysztof Kozlowski <[email protected]>Best regards,
KrzysztofQuoted 47 lines
Signed-off-by Amitoj Kaur Chawla <[email protected]>--- drivers/media/platform/exynos4-is/media-dev.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)drivers/media/platform/exynos4-is/media-dev.c +9
-3@@ -430,8 +430,10 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd)continue ; ret =fimc_md_parse_port_node (fmd, port, index); -if (ret <0 ) +if (ret <0 ) { +of_node_put (node); goto rpm_put; + } index++; }@@ -442,8 +444,10 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd)for_each_child_of_node (ports, node) { ret =fimc_md_parse_port_node (fmd, node, index); -if (ret <0 ) +if (ret <0 ) { +of_node_put (node);break ; + } index++; } rpm_put:@@ -651,8 +655,10 @@ static int fimc_md_register_platform_entities(struct fimc_md *fmd, ret =fimc_md_register_platform_entity (fmd, pdev, plat_entity);put_device (&pdev->dev); -if (ret <0 ) +if (ret <0 ) { +of_node_put (node);break ; + } }return ret;
Quoted 36 lines · Julia Lawall
Quoted 32 lines · Krzysztof Kozlowski
Quoted 15 lines · Amitoj Kaur Chawla
for_each_available_child_of_nodeandfor_each_child_of_nodeperform anof_node_geton each iteration, so to break out of the loop anof_node_putis required.Found using Coccinelle. The simplified version of the semantic patch that is used for this is as follows:
// <smpl>
@@
local idexpression n;
expression e,r;
@@for_each_available_child_of_node(r,n) { ...Quoted 12 lines
(
of_node_put(n);
|
e = n
|
+of_node_put(n);
? break;
)
...
}
... when != n
// </smpl>Patch iselft looks correct but why are you pasting coccinelle script into the message?
Quoted 8 lines
Quoted 2 lines
The script is already present in Linux kernel:
scripts/coccinelle/iterators/device_node_continue.cocciI don't think so. The continue one takes care of the case where there is an extraneous
of_node_putbefore a continue, not a missing one before a break. But OK to drop it if it doesn't seem useful.julia
You are right - this is not covered by that cocci patch... but I think is covered by scripts/coccinelle/iterators/fen.cocci, isn't it?
BR,
Krzysztof
Quoted 13 lines
Quoted 13 lines
This just extends the commit message without any meaningful data so with removal of coccinelle script above:
Reviewed-by Krzysztof Kozlowski <[email protected]>Best regards,
KrzysztofQuoted 5 lines
Signed-off-by Amitoj Kaur Chawla <[email protected]>--- drivers/media/platform/exynos4-is/media-dev.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
Quoted 40 lines · Krzysztof Kozlowski
Quoted 39 lines · Julia Lawall
Quoted 34 lines · Krzysztof Kozlowski
Quoted 15 lines · Amitoj Kaur Chawla
for_each_available_child_of_nodeandfor_each_child_of_nodeperform anof_node_geton each iteration, so to break out of the loop anof_node_putis required.Found using Coccinelle. The simplified version of the semantic patch that is used for this is as follows:
// <smpl>
@@
local idexpression n;
expression e,r;
@@for_each_available_child_of_node(r,n) { ...Quoted 12 lines
(
of_node_put(n);
|
e = n
|
+of_node_put(n);
? break;
)
...
}
... when != n
// </smpl>Patch iselft looks correct but why are you pasting coccinelle script into the message?
The script is already present in Linux kernel:
scripts/coccinelle/iterators/device_node_continue.cocci
Quoted 8 lines
Quoted 5 lines
I don't think so. The continue one takes care of the case where there is an extraneous
of_node_putbefore a continue, not a missing one before a break. But OK to drop it if it doesn't seem useful.julia
You are right - this is not covered by that cocci patch... but I think is covered by
scripts/coccinelle/iterators/fen.cocci, isn't it?
Not quite. That is for of_node_puts after normal loop completion (not sure that this problem comes up any more, but at one point there were a number of them). There are indeed a lot of ways in which the management of reference counts can go wrong...
Anyway, the rule that Amitoj used seems to be pretty reliable, so I'll try to get it into the kernel source tree some day soon.
julia
Quoted 19 lines
BR,
KrzysztofQuoted 13 lines
Quoted 13 lines
This just extends the commit message without any meaningful data so with removal of coccinelle script above:
Reviewed-by Krzysztof Kozlowski <[email protected]>Best regards,
KrzysztofQuoted 5 lines
Signed-off-by Amitoj Kaur Chawla <[email protected]>--- drivers/media/platform/exynos4-is/media-dev.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
Em Tue, 26 Jan 2016 08:12:15 +0100
Julia Lawall <[email protected]> escreveu:
Quoted 46 lines · Krzysztof Kozlowski
Quoted 45 lines · Julia Lawall
Quoted 43 lines · Krzysztof Kozlowski
Quoted 30 lines · Amitoj Kaur Chawla
Quoted 15 lines
for_each_available_child_of_nodeandfor_each_child_of_nodeperform anof_node_geton each iteration, so to break out of the loop anof_node_putis required.Found using Coccinelle. The simplified version of the semantic patch that is used for this is as follows:
// <smpl>
@@
local idexpression n;
expression e,r;
@@for_each_available_child_of_node(r,n) { ...Quoted 12 lines
(
of_node_put(n);
|
e = n
|
+of_node_put(n);
? break;
)
...
}
... when != n
// </smpl>Quoted 5 lines
Patch iselft looks correct but why are you pasting coccinelle script into the message?
The script is already present in Linux kernel:
scripts/coccinelle/iterators/device_node_continue.cocciI don't think so. The continue one takes care of the case where there is an extraneous
of_node_putbefore a continue, not a missing one before a break. But OK to drop it if it doesn't seem useful.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
julia
You are right - this is not covered by that cocci patch... but I think is covered by
scripts/coccinelle/iterators/fen.cocci, isn't it?Not quite.
If the script is not part of the Kernel, please keep the script in the patch, as it could be useful in some future.
Regards,
Mauro