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>
Signed-off-by: Amitoj Kaur Chawla <redacted>
---
drivers/media/platform/exynos4-is/media-dev.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
From: Krzysztof Kozlowski <hidden> Date: 2016-01-26 00:24:43
On 26.01.2016 00:21, Amitoj Kaur Chawla wrote:
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>
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:
Reviewed-by: Krzysztof Kozlowski <redacted>
Best regards,
Krzysztof
From: Julia Lawall <hidden> Date: 2016-01-26 06:24:50
On Tue, 26 Jan 2016, Krzysztof Kozlowski wrote:
On 26.01.2016 00:21, Amitoj Kaur Chawla wrote:
quoted
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>
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
This just extends the commit message without any meaningful data so with
removal of coccinelle script above:
Reviewed-by: Krzysztof Kozlowski <redacted>
Best regards,
Krzysztof
From: Krzysztof Kozlowski <hidden> Date: 2016-01-26 06:55:36
On 26.01.2016 15:24, Julia Lawall wrote:
On Tue, 26 Jan 2016, Krzysztof Kozlowski wrote:
quoted
On 26.01.2016 00:21, Amitoj Kaur Chawla wrote:
quoted
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>
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
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
This just extends the commit message without any meaningful data so with
removal of coccinelle script above:
Reviewed-by: Krzysztof Kozlowski <redacted>
Best regards,
Krzysztof
From: Julia Lawall <hidden> Date: 2016-01-26 07:12:21
On Tue, 26 Jan 2016, Krzysztof Kozlowski wrote:
On 26.01.2016 15:24, Julia Lawall wrote:
quoted
On Tue, 26 Jan 2016, Krzysztof Kozlowski wrote:
quoted
On 26.01.2016 00:21, Amitoj Kaur Chawla wrote:
quoted
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>
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
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
BR,
Krzysztof
quoted
quoted
This just extends the commit message without any meaningful data so with
removal of coccinelle script above:
Reviewed-by: Krzysztof Kozlowski <redacted>
Best regards,
Krzysztof
Em Tue, 26 Jan 2016 08:12:15 +0100
Julia Lawall [off-list ref] escreveu:
On Tue, 26 Jan 2016, Krzysztof Kozlowski wrote:
quoted
On 26.01.2016 15:24, Julia Lawall wrote:
quoted
On Tue, 26 Jan 2016, Krzysztof Kozlowski wrote:
quoted
On 26.01.2016 00:21, Amitoj Kaur Chawla wrote:
quoted
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>
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
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