* [PATCH 0/2] Bluetooth: btbcm: fix missing of_node_put() in btbcm_get_board_name()
@ 2024-10-30 15:46 Javier Carrasco
2024-10-30 15:46 ` [PATCH 1/2] " Javier Carrasco
2024-10-30 15:46 ` [PATCH 2/2] Bluetooth: btbcm: automate node cleanup " Javier Carrasco
0 siblings, 2 replies; 12+ messages in thread
From: Javier Carrasco @ 2024-10-30 15:46 UTC (permalink / raw)
To: Marcel Holtmann, Luiz Augusto von Dentz, Linus Walleij
Cc: linux-bluetooth, linux-kernel, Javier Carrasco, stable
This series fixes a missing call to of_node_put() in two steps: first
adding the call (compatible with all affected kernels), and then moving
to a more robust approach once the issue is fixed.
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
Javier Carrasco (2):
Bluetooth: btbcm: fix missing of_node_put() in btbcm_get_board_name()
Bluetooth: btbcm: automate node cleanup in btbcm_get_board_name()
drivers/bluetooth/btbcm.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
---
base-commit: 6fb2fa9805c501d9ade047fc511961f3273cdcb5
change-id: 20241030-bluetooth-btbcm-node-cleanup-23d21a73870c
Best regards,
--
Javier Carrasco <javier.carrasco.cruz@gmail.com>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/2] Bluetooth: btbcm: fix missing of_node_put() in btbcm_get_board_name()
2024-10-30 15:46 [PATCH 0/2] Bluetooth: btbcm: fix missing of_node_put() in btbcm_get_board_name() Javier Carrasco
@ 2024-10-30 15:46 ` Javier Carrasco
2024-10-30 15:46 ` [PATCH 2/2] Bluetooth: btbcm: automate node cleanup " Javier Carrasco
1 sibling, 0 replies; 12+ messages in thread
From: Javier Carrasco @ 2024-10-30 15:46 UTC (permalink / raw)
To: Marcel Holtmann, Luiz Augusto von Dentz, Linus Walleij
Cc: linux-bluetooth, linux-kernel, Javier Carrasco, stable
Add the missing call lto of_node_put(root) in the early return to
decrement the refcount and avoid leaking the resource.
Cc: stable@vger.kernel.org
Fixes: 63fac3343b99 ("Bluetooth: btbcm: Support per-board firmware variants")
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
drivers/bluetooth/btbcm.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
index eef00467905e..400c2663d6b0 100644
--- a/drivers/bluetooth/btbcm.c
+++ b/drivers/bluetooth/btbcm.c
@@ -549,8 +549,10 @@ static const char *btbcm_get_board_name(struct device *dev)
if (!root)
return NULL;
- if (of_property_read_string_index(root, "compatible", 0, &tmp))
+ if (of_property_read_string_index(root, "compatible", 0, &tmp)) {
+ of_node_put(root);
return NULL;
+ }
/* get rid of any '/' in the compatible string */
board_type = devm_kstrdup(dev, tmp, GFP_KERNEL);
--
2.43.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/2] Bluetooth: btbcm: automate node cleanup in btbcm_get_board_name()
2024-10-30 15:46 [PATCH 0/2] Bluetooth: btbcm: fix missing of_node_put() in btbcm_get_board_name() Javier Carrasco
2024-10-30 15:46 ` [PATCH 1/2] " Javier Carrasco
@ 2024-10-30 15:46 ` Javier Carrasco
2024-10-31 11:08 ` Krzysztof Kozlowski
1 sibling, 1 reply; 12+ messages in thread
From: Javier Carrasco @ 2024-10-30 15:46 UTC (permalink / raw)
To: Marcel Holtmann, Luiz Augusto von Dentz, Linus Walleij
Cc: linux-bluetooth, linux-kernel, Javier Carrasco
Switch to a more robust approach by automating the node release when it
goes out of scope, removing the need for explicit calls to
of_node_put().
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
drivers/bluetooth/btbcm.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
index 400c2663d6b0..a1153ada74d2 100644
--- a/drivers/bluetooth/btbcm.c
+++ b/drivers/bluetooth/btbcm.c
@@ -541,23 +541,19 @@ static const struct bcm_subver_table bcm_usb_subver_table[] = {
static const char *btbcm_get_board_name(struct device *dev)
{
#ifdef CONFIG_OF
- struct device_node *root;
+ struct device_node *root __free(device_node) = of_find_node_by_path("/");
char *board_type;
const char *tmp;
- root = of_find_node_by_path("/");
if (!root)
return NULL;
- if (of_property_read_string_index(root, "compatible", 0, &tmp)) {
- of_node_put(root);
+ if (of_property_read_string_index(root, "compatible", 0, &tmp))
return NULL;
- }
/* get rid of any '/' in the compatible string */
board_type = devm_kstrdup(dev, tmp, GFP_KERNEL);
strreplace(board_type, '/', '-');
- of_node_put(root);
return board_type;
#else
--
2.43.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 2/2] Bluetooth: btbcm: automate node cleanup in btbcm_get_board_name()
2024-10-30 15:46 ` [PATCH 2/2] Bluetooth: btbcm: automate node cleanup " Javier Carrasco
@ 2024-10-31 11:08 ` Krzysztof Kozlowski
2024-10-31 11:10 ` Javier Carrasco
0 siblings, 1 reply; 12+ messages in thread
From: Krzysztof Kozlowski @ 2024-10-31 11:08 UTC (permalink / raw)
To: Javier Carrasco, Marcel Holtmann, Luiz Augusto von Dentz,
Linus Walleij
Cc: linux-bluetooth, linux-kernel
On 30/10/2024 16:46, Javier Carrasco wrote:
> Switch to a more robust approach by automating the node release when it
> goes out of scope, removing the need for explicit calls to
> of_node_put().
>
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
> ---
> drivers/bluetooth/btbcm.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
> index 400c2663d6b0..a1153ada74d2 100644
> --- a/drivers/bluetooth/btbcm.c
> +++ b/drivers/bluetooth/btbcm.c
> @@ -541,23 +541,19 @@ static const struct bcm_subver_table bcm_usb_subver_table[] = {
> static const char *btbcm_get_board_name(struct device *dev)
> {
> #ifdef CONFIG_OF
> - struct device_node *root;
> + struct device_node *root __free(device_node) = of_find_node_by_path("/");
> char *board_type;
> const char *tmp;
>
> - root = of_find_node_by_path("/");
> if (!root)
> return NULL;
>
> - if (of_property_read_string_index(root, "compatible", 0, &tmp)) {
> - of_node_put(root);
You just added this. Don't add code which is immediately removed. It's a
noop or wrong code.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/2] Bluetooth: btbcm: automate node cleanup in btbcm_get_board_name()
2024-10-31 11:08 ` Krzysztof Kozlowski
@ 2024-10-31 11:10 ` Javier Carrasco
2024-10-31 11:14 ` Krzysztof Kozlowski
0 siblings, 1 reply; 12+ messages in thread
From: Javier Carrasco @ 2024-10-31 11:10 UTC (permalink / raw)
To: Krzysztof Kozlowski, Marcel Holtmann, Luiz Augusto von Dentz,
Linus Walleij
Cc: linux-bluetooth, linux-kernel
On 31/10/2024 12:08, Krzysztof Kozlowski wrote:
> On 30/10/2024 16:46, Javier Carrasco wrote:
>> Switch to a more robust approach by automating the node release when it
>> goes out of scope, removing the need for explicit calls to
>> of_node_put().
>>
>> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
>> ---
>> drivers/bluetooth/btbcm.c | 8 ++------
>> 1 file changed, 2 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
>> index 400c2663d6b0..a1153ada74d2 100644
>> --- a/drivers/bluetooth/btbcm.c
>> +++ b/drivers/bluetooth/btbcm.c
>> @@ -541,23 +541,19 @@ static const struct bcm_subver_table bcm_usb_subver_table[] = {
>> static const char *btbcm_get_board_name(struct device *dev)
>> {
>> #ifdef CONFIG_OF
>> - struct device_node *root;
>> + struct device_node *root __free(device_node) = of_find_node_by_path("/");
>> char *board_type;
>> const char *tmp;
>>
>> - root = of_find_node_by_path("/");
>> if (!root)
>> return NULL;
>>
>> - if (of_property_read_string_index(root, "compatible", 0, &tmp)) {
>> - of_node_put(root);
>
> You just added this. Don't add code which is immediately removed. It's a
> noop or wrong code.
>
>
>
> Best regards,
> Krzysztof
>
Exactly, I added that code to fix the issue in stable kernels that don't
support the __free() macro, and then I removed it to use a safer
approach from now on.
Best regards,
Javier Carrasco
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/2] Bluetooth: btbcm: automate node cleanup in btbcm_get_board_name()
2024-10-31 11:10 ` Javier Carrasco
@ 2024-10-31 11:14 ` Krzysztof Kozlowski
2024-10-31 11:29 ` Javier Carrasco
2024-10-31 11:30 ` Krzysztof Kozlowski
0 siblings, 2 replies; 12+ messages in thread
From: Krzysztof Kozlowski @ 2024-10-31 11:14 UTC (permalink / raw)
To: Javier Carrasco, Marcel Holtmann, Luiz Augusto von Dentz,
Linus Walleij
Cc: linux-bluetooth, linux-kernel
On 31/10/2024 12:10, Javier Carrasco wrote:
> On 31/10/2024 12:08, Krzysztof Kozlowski wrote:
>> On 30/10/2024 16:46, Javier Carrasco wrote:
>>> Switch to a more robust approach by automating the node release when it
>>> goes out of scope, removing the need for explicit calls to
>>> of_node_put().
>>>
>>> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
>>> ---
>>> drivers/bluetooth/btbcm.c | 8 ++------
>>> 1 file changed, 2 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
>>> index 400c2663d6b0..a1153ada74d2 100644
>>> --- a/drivers/bluetooth/btbcm.c
>>> +++ b/drivers/bluetooth/btbcm.c
>>> @@ -541,23 +541,19 @@ static const struct bcm_subver_table bcm_usb_subver_table[] = {
>>> static const char *btbcm_get_board_name(struct device *dev)
>>> {
>>> #ifdef CONFIG_OF
>>> - struct device_node *root;
>>> + struct device_node *root __free(device_node) = of_find_node_by_path("/");
>>> char *board_type;
>>> const char *tmp;
>>>
>>> - root = of_find_node_by_path("/");
>>> if (!root)
>>> return NULL;
>>>
>>> - if (of_property_read_string_index(root, "compatible", 0, &tmp)) {
>>> - of_node_put(root);
>>
>> You just added this. Don't add code which is immediately removed. It's a
>> noop or wrong code.
>>
>>
>>
>> Best regards,
>> Krzysztof
>>
>
> Exactly, I added that code to fix the issue in stable kernels that don't
Then send backport for stable.
> support the __free() macro, and then I removed it to use a safer
> approach from now on.
This is not correct approach. We work here on mainline and in mainline
this is one logical change: fixing issue. Whether you fix issue with
of_node_put or cleanup or by removing of_find_node_by_path() call, it
does not matter. All of these are fixing the same, one issue.
If you think about stable kernels, then work on backports, not inflate
mainline kernel with multiple commits doing the same, creating
artificial history.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/2] Bluetooth: btbcm: automate node cleanup in btbcm_get_board_name()
2024-10-31 11:14 ` Krzysztof Kozlowski
@ 2024-10-31 11:29 ` Javier Carrasco
2024-10-31 11:33 ` Krzysztof Kozlowski
2024-10-31 11:44 ` Krzysztof Kozlowski
2024-10-31 11:30 ` Krzysztof Kozlowski
1 sibling, 2 replies; 12+ messages in thread
From: Javier Carrasco @ 2024-10-31 11:29 UTC (permalink / raw)
To: Krzysztof Kozlowski, Marcel Holtmann, Luiz Augusto von Dentz,
Linus Walleij
Cc: linux-bluetooth, linux-kernel
On 31/10/2024 12:14, Krzysztof Kozlowski wrote:
> On 31/10/2024 12:10, Javier Carrasco wrote:
>> On 31/10/2024 12:08, Krzysztof Kozlowski wrote:
>>> On 30/10/2024 16:46, Javier Carrasco wrote:
>>>> Switch to a more robust approach by automating the node release when it
>>>> goes out of scope, removing the need for explicit calls to
>>>> of_node_put().
>>>>
>>>> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
>>>> ---
>>>> drivers/bluetooth/btbcm.c | 8 ++------
>>>> 1 file changed, 2 insertions(+), 6 deletions(-)
>>>>
>>>> diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
>>>> index 400c2663d6b0..a1153ada74d2 100644
>>>> --- a/drivers/bluetooth/btbcm.c
>>>> +++ b/drivers/bluetooth/btbcm.c
>>>> @@ -541,23 +541,19 @@ static const struct bcm_subver_table bcm_usb_subver_table[] = {
>>>> static const char *btbcm_get_board_name(struct device *dev)
>>>> {
>>>> #ifdef CONFIG_OF
>>>> - struct device_node *root;
>>>> + struct device_node *root __free(device_node) = of_find_node_by_path("/");
>>>> char *board_type;
>>>> const char *tmp;
>>>>
>>>> - root = of_find_node_by_path("/");
>>>> if (!root)
>>>> return NULL;
>>>>
>>>> - if (of_property_read_string_index(root, "compatible", 0, &tmp)) {
>>>> - of_node_put(root);
>>>
>>> You just added this. Don't add code which is immediately removed. It's a
>>> noop or wrong code.
>>>
>>>
>>>
>>> Best regards,
>>> Krzysztof
>>>
>>
>> Exactly, I added that code to fix the issue in stable kernels that don't
>
> Then send backport for stable.
>
>> support the __free() macro, and then I removed it to use a safer
>> approach from now on.
>
> This is not correct approach. We work here on mainline and in mainline
> this is one logical change: fixing issue. Whether you fix issue with
> of_node_put or cleanup or by removing of_find_node_by_path() call, it
> does not matter. All of these are fixing the same, one issue.
>
I fixed an issue as one logical change, and tagged it for stable kernels
so it can be automatically applied. Then a second logical change
switched to the new approach, removing the old solution. If that
happened with a few weeks in between, it would be ok, right? And no one
would have to choose the fixes to backport for a given stable kernel.
I have also had cases where the maintainer preferred my approach instead
of fixing an old bug with a new facility, and the suggestion was
splitting into two patches.
But in the end I want to fix the issue in mainline kernel, so I will
squash the patches and leave the backporting for the ones who might be
interested in it, removing the stable tag.
> If you think about stable kernels, then work on backports, not inflate
> mainline kernel with multiple commits doing the same, creating
> artificial history.
>
> Best regards,
> Krzysztof
>
Thanks for your feedback and best regards,
Javier Carrasco
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/2] Bluetooth: btbcm: automate node cleanup in btbcm_get_board_name()
2024-10-31 11:14 ` Krzysztof Kozlowski
2024-10-31 11:29 ` Javier Carrasco
@ 2024-10-31 11:30 ` Krzysztof Kozlowski
2024-10-31 11:41 ` Javier Carrasco
1 sibling, 1 reply; 12+ messages in thread
From: Krzysztof Kozlowski @ 2024-10-31 11:30 UTC (permalink / raw)
To: Javier Carrasco, Marcel Holtmann, Luiz Augusto von Dentz,
Linus Walleij
Cc: linux-bluetooth, linux-kernel
On 31/10/2024 12:14, Krzysztof Kozlowski wrote:
> On 31/10/2024 12:10, Javier Carrasco wrote:
>> On 31/10/2024 12:08, Krzysztof Kozlowski wrote:
>>> On 30/10/2024 16:46, Javier Carrasco wrote:
>>>> Switch to a more robust approach by automating the node release when it
>>>> goes out of scope, removing the need for explicit calls to
>>>> of_node_put().
>>>>
>>>> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
>>>> ---
>>>> drivers/bluetooth/btbcm.c | 8 ++------
>>>> 1 file changed, 2 insertions(+), 6 deletions(-)
>>>>
>>>> diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
>>>> index 400c2663d6b0..a1153ada74d2 100644
>>>> --- a/drivers/bluetooth/btbcm.c
>>>> +++ b/drivers/bluetooth/btbcm.c
>>>> @@ -541,23 +541,19 @@ static const struct bcm_subver_table bcm_usb_subver_table[] = {
>>>> static const char *btbcm_get_board_name(struct device *dev)
>>>> {
>>>> #ifdef CONFIG_OF
>>>> - struct device_node *root;
>>>> + struct device_node *root __free(device_node) = of_find_node_by_path("/");
>>>> char *board_type;
>>>> const char *tmp;
>>>>
>>>> - root = of_find_node_by_path("/");
>>>> if (!root)
>>>> return NULL;
>>>>
>>>> - if (of_property_read_string_index(root, "compatible", 0, &tmp)) {
>>>> - of_node_put(root);
>>>
>>> You just added this. Don't add code which is immediately removed. It's a
>>> noop or wrong code.
>>>
>>>
>>>
>>> Best regards,
>>> Krzysztof
>>>
>>
>> Exactly, I added that code to fix the issue in stable kernels that don't
>
> Then send backport for stable.
>
>> support the __free() macro, and then I removed it to use a safer
>> approach from now on.
>
> This is not correct approach. We work here on mainline and in mainline
> this is one logical change: fixing issue. Whether you fix issue with
> of_node_put or cleanup or by removing of_find_node_by_path() call, it
> does not matter. All of these are fixing the same, one issue.
>
> If you think about stable kernels, then work on backports, not inflate
> mainline kernel with multiple commits doing the same, creating
> artificial history.
>
And to clarify even more: these stable backports are close to useless,
because it does not matter for them. No impact, not much benefits,
nothing improved for users/developers. There is no need to backport
them, although of course there is no loss by doing so. Therefore entire
dance affects mainline kernel without any real benefits for stable.
Your split suggests you don't really know what this dropping reference
is for.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/2] Bluetooth: btbcm: automate node cleanup in btbcm_get_board_name()
2024-10-31 11:29 ` Javier Carrasco
@ 2024-10-31 11:33 ` Krzysztof Kozlowski
2024-10-31 11:44 ` Krzysztof Kozlowski
1 sibling, 0 replies; 12+ messages in thread
From: Krzysztof Kozlowski @ 2024-10-31 11:33 UTC (permalink / raw)
To: Javier Carrasco, Marcel Holtmann, Luiz Augusto von Dentz,
Linus Walleij
Cc: linux-bluetooth, linux-kernel
On 31/10/2024 12:29, Javier Carrasco wrote:
> On 31/10/2024 12:14, Krzysztof Kozlowski wrote:
>> On 31/10/2024 12:10, Javier Carrasco wrote:
>>> On 31/10/2024 12:08, Krzysztof Kozlowski wrote:
>>>> On 30/10/2024 16:46, Javier Carrasco wrote:
>>>>> Switch to a more robust approach by automating the node release when it
>>>>> goes out of scope, removing the need for explicit calls to
>>>>> of_node_put().
>>>>>
>>>>> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
>>>>> ---
>>>>> drivers/bluetooth/btbcm.c | 8 ++------
>>>>> 1 file changed, 2 insertions(+), 6 deletions(-)
>>>>>
>>>>> diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
>>>>> index 400c2663d6b0..a1153ada74d2 100644
>>>>> --- a/drivers/bluetooth/btbcm.c
>>>>> +++ b/drivers/bluetooth/btbcm.c
>>>>> @@ -541,23 +541,19 @@ static const struct bcm_subver_table bcm_usb_subver_table[] = {
>>>>> static const char *btbcm_get_board_name(struct device *dev)
>>>>> {
>>>>> #ifdef CONFIG_OF
>>>>> - struct device_node *root;
>>>>> + struct device_node *root __free(device_node) = of_find_node_by_path("/");
>>>>> char *board_type;
>>>>> const char *tmp;
>>>>>
>>>>> - root = of_find_node_by_path("/");
>>>>> if (!root)
>>>>> return NULL;
>>>>>
>>>>> - if (of_property_read_string_index(root, "compatible", 0, &tmp)) {
>>>>> - of_node_put(root);
>>>>
>>>> You just added this. Don't add code which is immediately removed. It's a
>>>> noop or wrong code.
>>>>
>>>>
>>>>
>>>> Best regards,
>>>> Krzysztof
>>>>
>>>
>>> Exactly, I added that code to fix the issue in stable kernels that don't
>>
>> Then send backport for stable.
>>
>>> support the __free() macro, and then I removed it to use a safer
>>> approach from now on.
>>
>> This is not correct approach. We work here on mainline and in mainline
>> this is one logical change: fixing issue. Whether you fix issue with
>> of_node_put or cleanup or by removing of_find_node_by_path() call, it
>> does not matter. All of these are fixing the same, one issue.
>>
>
> I fixed an issue as one logical change, and tagged it for stable kernels
> so it can be automatically applied. Then a second logical change
> switched to the new approach, removing the old solution. If that
> happened with a few weeks in between, it would be ok, right? And no one
> would have to choose the fixes to backport for a given stable kernel.
>
> I have also had cases where the maintainer preferred my approach instead
> of fixing an old bug with a new facility, and the suggestion was
> splitting into two patches.
But this fix does not matter for stable kernels. Please describe any
real, observable benefit by backporting it to old kernel which does not
support cleanup.h.
>
> But in the end I want to fix the issue in mainline kernel, so I will
> squash the patches and leave the backporting for the ones who might be
> interested in it, removing the stable tag.
Why removing stable tag? This is still fixing issue and if previously
you wanted to indicate possible backport, then now as well. Stable
kernel do support or, if some don't, might support cleanup.h.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/2] Bluetooth: btbcm: automate node cleanup in btbcm_get_board_name()
2024-10-31 11:30 ` Krzysztof Kozlowski
@ 2024-10-31 11:41 ` Javier Carrasco
2024-10-31 11:46 ` Krzysztof Kozlowski
0 siblings, 1 reply; 12+ messages in thread
From: Javier Carrasco @ 2024-10-31 11:41 UTC (permalink / raw)
To: Krzysztof Kozlowski, Marcel Holtmann, Luiz Augusto von Dentz,
Linus Walleij
Cc: linux-bluetooth, linux-kernel
On 31/10/2024 12:30, Krzysztof Kozlowski wrote:
> On 31/10/2024 12:14, Krzysztof Kozlowski wrote:
>> On 31/10/2024 12:10, Javier Carrasco wrote:
>>> On 31/10/2024 12:08, Krzysztof Kozlowski wrote:
>>>> On 30/10/2024 16:46, Javier Carrasco wrote:
>>>>> Switch to a more robust approach by automating the node release when it
>>>>> goes out of scope, removing the need for explicit calls to
>>>>> of_node_put().
>>>>>
>>>>> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
>>>>> ---
>>>>> drivers/bluetooth/btbcm.c | 8 ++------
>>>>> 1 file changed, 2 insertions(+), 6 deletions(-)
>>>>>
>>>>> diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
>>>>> index 400c2663d6b0..a1153ada74d2 100644
>>>>> --- a/drivers/bluetooth/btbcm.c
>>>>> +++ b/drivers/bluetooth/btbcm.c
>>>>> @@ -541,23 +541,19 @@ static const struct bcm_subver_table bcm_usb_subver_table[] = {
>>>>> static const char *btbcm_get_board_name(struct device *dev)
>>>>> {
>>>>> #ifdef CONFIG_OF
>>>>> - struct device_node *root;
>>>>> + struct device_node *root __free(device_node) = of_find_node_by_path("/");
>>>>> char *board_type;
>>>>> const char *tmp;
>>>>>
>>>>> - root = of_find_node_by_path("/");
>>>>> if (!root)
>>>>> return NULL;
>>>>>
>>>>> - if (of_property_read_string_index(root, "compatible", 0, &tmp)) {
>>>>> - of_node_put(root);
>>>>
>>>> You just added this. Don't add code which is immediately removed. It's a
>>>> noop or wrong code.
>>>>
>>>>
>>>>
>>>> Best regards,
>>>> Krzysztof
>>>>
>>>
>>> Exactly, I added that code to fix the issue in stable kernels that don't
>>
>> Then send backport for stable.
>>
>>> support the __free() macro, and then I removed it to use a safer
>>> approach from now on.
>>
>> This is not correct approach. We work here on mainline and in mainline
>> this is one logical change: fixing issue. Whether you fix issue with
>> of_node_put or cleanup or by removing of_find_node_by_path() call, it
>> does not matter. All of these are fixing the same, one issue.
>>
>> If you think about stable kernels, then work on backports, not inflate
>> mainline kernel with multiple commits doing the same, creating
>> artificial history.
>>
>
> And to clarify even more: these stable backports are close to useless,
> because it does not matter for them. No impact, not much benefits,
> nothing improved for users/developers. There is no need to backport
> them, although of course there is no loss by doing so. Therefore entire
> dance affects mainline kernel without any real benefits for stable.
>
> Your split suggests you don't really know what this dropping reference
> is for.
Such splits were suggested in other threads, and they came exactly for
those reasons: they could not be applied to stable. That was not my
first approach, which was just using __free() to fix the issue. I am not
looking forward to inflating any history, as that's in the end more work
for me.
If a simple patch that adds the cleanup attribute is enough, that's
awesome. I will go for that approach for all cases then, and use your
explanation as a reference if I am asked to split the fix again.
> Best regards,
> Krzysztof
>
Thanks for your feedback and best regards,
Javier Carrasco
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/2] Bluetooth: btbcm: automate node cleanup in btbcm_get_board_name()
2024-10-31 11:29 ` Javier Carrasco
2024-10-31 11:33 ` Krzysztof Kozlowski
@ 2024-10-31 11:44 ` Krzysztof Kozlowski
1 sibling, 0 replies; 12+ messages in thread
From: Krzysztof Kozlowski @ 2024-10-31 11:44 UTC (permalink / raw)
To: Javier Carrasco, Marcel Holtmann, Luiz Augusto von Dentz,
Linus Walleij
Cc: linux-bluetooth, linux-kernel
On 31/10/2024 12:29, Javier Carrasco wrote:
> On 31/10/2024 12:14, Krzysztof Kozlowski wrote:
>> On 31/10/2024 12:10, Javier Carrasco wrote:
>>> On 31/10/2024 12:08, Krzysztof Kozlowski wrote:
>>>> On 30/10/2024 16:46, Javier Carrasco wrote:
>>>>> Switch to a more robust approach by automating the node release when it
>>>>> goes out of scope, removing the need for explicit calls to
>>>>> of_node_put().
>>>>>
>>>>> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
>>>>> ---
>>>>> drivers/bluetooth/btbcm.c | 8 ++------
>>>>> 1 file changed, 2 insertions(+), 6 deletions(-)
>>>>>
>>>>> diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
>>>>> index 400c2663d6b0..a1153ada74d2 100644
>>>>> --- a/drivers/bluetooth/btbcm.c
>>>>> +++ b/drivers/bluetooth/btbcm.c
>>>>> @@ -541,23 +541,19 @@ static const struct bcm_subver_table bcm_usb_subver_table[] = {
>>>>> static const char *btbcm_get_board_name(struct device *dev)
>>>>> {
>>>>> #ifdef CONFIG_OF
>>>>> - struct device_node *root;
>>>>> + struct device_node *root __free(device_node) = of_find_node_by_path("/");
>>>>> char *board_type;
>>>>> const char *tmp;
>>>>>
>>>>> - root = of_find_node_by_path("/");
>>>>> if (!root)
>>>>> return NULL;
>>>>>
>>>>> - if (of_property_read_string_index(root, "compatible", 0, &tmp)) {
>>>>> - of_node_put(root);
>>>>
>>>> You just added this. Don't add code which is immediately removed. It's a
>>>> noop or wrong code.
>>>>
>>>>
>>>>
>>>> Best regards,
>>>> Krzysztof
>>>>
>>>
>>> Exactly, I added that code to fix the issue in stable kernels that don't
>>
>> Then send backport for stable.
>>
>>> support the __free() macro, and then I removed it to use a safer
>>> approach from now on.
>>
>> This is not correct approach. We work here on mainline and in mainline
>> this is one logical change: fixing issue. Whether you fix issue with
>> of_node_put or cleanup or by removing of_find_node_by_path() call, it
>> does not matter. All of these are fixing the same, one issue.
>>
>
> I fixed an issue as one logical change, and tagged it for stable kernels
> so it can be automatically applied. Then a second logical change
> switched to the new approach, removing the old solution. If that
> happened with a few weeks in between, it would be ok, right? And no one
> would have to choose the fixes to backport for a given stable kernel.
I did not address this.
That's the same with every work in the kernel. You create a driver and
you send it. It's one commit, for regular cases of drivers (not too
big). You do not send two commits:
1. Add basic driver, built-in because supporting module is difficult.
2. Add some feature, like converting built-in to module.
Now, because we all release early, release often you could release first
built-in driver and then come later (*later*) and develop second patch
improving it, e.g. converting to module.
It's exactly the same here. You fix issue. If you want to split your
contributions and release fixes early, sure, go on. It's different than
you know and you have the code ready which makes the first fix totally
obsolete.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/2] Bluetooth: btbcm: automate node cleanup in btbcm_get_board_name()
2024-10-31 11:41 ` Javier Carrasco
@ 2024-10-31 11:46 ` Krzysztof Kozlowski
0 siblings, 0 replies; 12+ messages in thread
From: Krzysztof Kozlowski @ 2024-10-31 11:46 UTC (permalink / raw)
To: Javier Carrasco, Marcel Holtmann, Luiz Augusto von Dentz,
Linus Walleij
Cc: linux-bluetooth, linux-kernel
On 31/10/2024 12:41, Javier Carrasco wrote:
> On 31/10/2024 12:30, Krzysztof Kozlowski wrote:
>> On 31/10/2024 12:14, Krzysztof Kozlowski wrote:
>>> On 31/10/2024 12:10, Javier Carrasco wrote:
>>>> On 31/10/2024 12:08, Krzysztof Kozlowski wrote:
>>>>> On 30/10/2024 16:46, Javier Carrasco wrote:
>>>>>> Switch to a more robust approach by automating the node release when it
>>>>>> goes out of scope, removing the need for explicit calls to
>>>>>> of_node_put().
>>>>>>
>>>>>> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
>>>>>> ---
>>>>>> drivers/bluetooth/btbcm.c | 8 ++------
>>>>>> 1 file changed, 2 insertions(+), 6 deletions(-)
>>>>>>
>>>>>> diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
>>>>>> index 400c2663d6b0..a1153ada74d2 100644
>>>>>> --- a/drivers/bluetooth/btbcm.c
>>>>>> +++ b/drivers/bluetooth/btbcm.c
>>>>>> @@ -541,23 +541,19 @@ static const struct bcm_subver_table bcm_usb_subver_table[] = {
>>>>>> static const char *btbcm_get_board_name(struct device *dev)
>>>>>> {
>>>>>> #ifdef CONFIG_OF
>>>>>> - struct device_node *root;
>>>>>> + struct device_node *root __free(device_node) = of_find_node_by_path("/");
>>>>>> char *board_type;
>>>>>> const char *tmp;
>>>>>>
>>>>>> - root = of_find_node_by_path("/");
>>>>>> if (!root)
>>>>>> return NULL;
>>>>>>
>>>>>> - if (of_property_read_string_index(root, "compatible", 0, &tmp)) {
>>>>>> - of_node_put(root);
>>>>>
>>>>> You just added this. Don't add code which is immediately removed. It's a
>>>>> noop or wrong code.
>>>>>
>>>>>
>>>>>
>>>>> Best regards,
>>>>> Krzysztof
>>>>>
>>>>
>>>> Exactly, I added that code to fix the issue in stable kernels that don't
>>>
>>> Then send backport for stable.
>>>
>>>> support the __free() macro, and then I removed it to use a safer
>>>> approach from now on.
>>>
>>> This is not correct approach. We work here on mainline and in mainline
>>> this is one logical change: fixing issue. Whether you fix issue with
>>> of_node_put or cleanup or by removing of_find_node_by_path() call, it
>>> does not matter. All of these are fixing the same, one issue.
>>>
>>> If you think about stable kernels, then work on backports, not inflate
>>> mainline kernel with multiple commits doing the same, creating
>>> artificial history.
>>>
>>
>> And to clarify even more: these stable backports are close to useless,
>> because it does not matter for them. No impact, not much benefits,
>> nothing improved for users/developers. There is no need to backport
>> them, although of course there is no loss by doing so. Therefore entire
>> dance affects mainline kernel without any real benefits for stable.
>>
>> Your split suggests you don't really know what this dropping reference
>> is for.
>
> Such splits were suggested in other threads, and they came exactly for
You mention it third time, but never provided a link. I tried to look
briefly for it but failed. Can you share a lore link?
> those reasons: they could not be applied to stable. That was not my
> first approach, which was just using __free() to fix the issue. I am not
> looking forward to inflating any history, as that's in the end more work
> for me.
>
> If a simple patch that adds the cleanup attribute is enough, that's
> awesome. I will go for that approach for all cases then, and use your
> explanation as a reference if I am asked to split the fix again.
If maintainer asks you to split trivial things like of_node_put() for
simple patches, feel free to Cc me, so I can provide counter arguments.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2024-10-31 11:46 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-30 15:46 [PATCH 0/2] Bluetooth: btbcm: fix missing of_node_put() in btbcm_get_board_name() Javier Carrasco
2024-10-30 15:46 ` [PATCH 1/2] " Javier Carrasco
2024-10-30 15:46 ` [PATCH 2/2] Bluetooth: btbcm: automate node cleanup " Javier Carrasco
2024-10-31 11:08 ` Krzysztof Kozlowski
2024-10-31 11:10 ` Javier Carrasco
2024-10-31 11:14 ` Krzysztof Kozlowski
2024-10-31 11:29 ` Javier Carrasco
2024-10-31 11:33 ` Krzysztof Kozlowski
2024-10-31 11:44 ` Krzysztof Kozlowski
2024-10-31 11:30 ` Krzysztof Kozlowski
2024-10-31 11:41 ` Javier Carrasco
2024-10-31 11:46 ` Krzysztof Kozlowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox