[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <955e5ed7-6469-4f17-9e8c-3ee06f5dc3bc@oss.qualcomm.com>
Date: Fri, 9 Jan 2026 16:20:25 +0100
From: Krzysztof Kozlowski <krzysztof.kozlowski@....qualcomm.com>
To: Gatien CHEVALLIER <gatien.chevallier@...s.st.com>,
Bjorn Andersson <andersson@...nel.org>,
Konrad Dybcio <konradybcio@...nel.org>,
Maxime Coquelin <mcoquelin.stm32@...il.com>,
Alexandre Torgue <alexandre.torgue@...s.st.com>,
linux-arm-msm@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-stm32@...md-mailman.stormreply.com,
linux-arm-kernel@...ts.infradead.org
Cc: Jonathan Cameron <jonathan.cameron@...wei.com>
Subject: Re: [PATCH v2 3/3] bus: stm32_firewall: Use scoped allocation to
simplify cleanup
On 09/01/2026 13:34, Gatien CHEVALLIER wrote:
>
>
> On 1/9/26 12:55, Krzysztof Kozlowski wrote:
>> On 09/01/2026 11:37, Gatien CHEVALLIER wrote:
>>> On 1/5/26 15:37, Krzysztof Kozlowski wrote:
>>>> Allocate the memory with scoped/cleanup.h to reduce error handling and
>>>> make the code a bit simpler.
>>>>
>>>> Suggested-by: Jonathan Cameron <jonathan.cameron@...wei.com>
>>>> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@....qualcomm.com>
>>>>
>>>> ---
>>>>
>>>> Changes in v2:
>>>> 1. New patch
>>>> ---
>>>> drivers/bus/stm32_firewall.c | 10 +++-------
>>>> 1 file changed, 3 insertions(+), 7 deletions(-)
>>>>
>>>> diff --git a/drivers/bus/stm32_firewall.c b/drivers/bus/stm32_firewall.c
>>>> index fae881cea9a0..92414a4c7bb1 100644
>>>> --- a/drivers/bus/stm32_firewall.c
>>>> +++ b/drivers/bus/stm32_firewall.c
>>>> @@ -240,7 +240,6 @@ EXPORT_SYMBOL_GPL(stm32_firewall_controller_unregister);
>>>>
>>>> int stm32_firewall_populate_bus(struct stm32_firewall_controller *firewall_controller)
>>>> {
>>>> - struct stm32_firewall *firewalls;
>>>> struct device *parent;
>>>> unsigned int i;
>>>> int len;
>>>> @@ -257,15 +256,14 @@ int stm32_firewall_populate_bus(struct stm32_firewall_controller *firewall_contr
>>>> if (len <= 0)
>>>> return -EINVAL;
>>>>
>>>> - firewalls = kcalloc(len, sizeof(*firewalls), GFP_KERNEL);
>>>> + struct stm32_firewall *firewalls __free(kfree) =
>>>> + kcalloc(len, sizeof(*firewalls), GFP_KERNEL);
>>>
>>> Hello,
>>>
>>> I'd prefer to keep declarations separated.
>>
>> Separated how? This is the coding style of cleanup (which is quite
>> explicit around other styles)? Or you meant one line without wrapping?
>>
>
> I found odd to declare and assign a variable mid-loop but I found
> multiple occurrences of the same kind of cleanup.
>
> You can drop my comment, I'm fine with how it is. Thanks for the
> cleanup.
>
Sure, just to let you know - it is fair to reject cleanup.h entirely for
code you maintain (like netdev did). I only disagree with sort of
semi-cleanup.h without following its declaration and initialization
rules, because it is more error-prone, leads to bugs and often does not
make the code easier to read/simpler.
Best regards,
Krzysztof
Powered by blists - more mailing lists