mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Gatien CHEVALLIER <gatien.chevallier@foss.st.com>
To: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>,
	"Bjorn Andersson" <andersson@kernel.org>,
	Konrad Dybcio <konradybcio@kernel.org>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Alexandre Torgue <alexandre.torgue@foss.st.com>,
	<linux-arm-msm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-stm32@st-md-mailman.stormreply.com>,
	<linux-arm-kernel@lists.infradead.org>
Cc: Jonathan Cameron <jonathan.cameron@huawei.com>
Subject: Re: [PATCH v2 3/3] bus: stm32_firewall: Use scoped allocation to simplify cleanup
Date: Fri, 9 Jan 2026 11:37:55 +0100	[thread overview]
Message-ID: <fe8bdea9-4bd2-4200-8b7c-3c231dc6dcb2@foss.st.com> (raw)
In-Reply-To: <20260105143657.383621-6-krzysztof.kozlowski@oss.qualcomm.com>

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@huawei.com>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.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.

Otherwise:

Tested-by: Gatien Chevallier <gatien.chevallier@foss.st.com>

Thank you,

Gatien

>   		if (!firewalls)
>   			return -ENOMEM;
>   
>   		err = stm32_firewall_get_firewall(child, firewalls, (unsigned int)len);
> -		if (err) {
> -			kfree(firewalls);
> +		if (err)
>   			return err;
> -		}
>   
>   		for (i = 0; i < len; i++) {
>   			if (firewall_controller->grant_access(firewall_controller,
> @@ -279,8 +277,6 @@ int stm32_firewall_populate_bus(struct stm32_firewall_controller *firewall_contr
>   					child->full_name);
>   			}
>   		}
> -
> -		kfree(firewalls);
>   	}
>   
>   	return 0;


  reply	other threads:[~2026-01-09 10:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-05 14:36 [PATCH v2 1/3] bus: qcom-ebi2: Simplify with scoped for each OF child loop Krzysztof Kozlowski
2026-01-05 14:36 ` [PATCH v2 2/3] bus: stm32_firewall: " Krzysztof Kozlowski
2026-01-09 10:33   ` Gatien CHEVALLIER
2026-01-05 14:37 ` [PATCH v2 3/3] bus: stm32_firewall: Use scoped allocation to simplify cleanup Krzysztof Kozlowski
2026-01-09 10:37   ` Gatien CHEVALLIER [this message]
2026-01-09 11:55     ` Krzysztof Kozlowski
2026-01-09 12:34       ` Gatien CHEVALLIER
2026-01-09 15:20         ` Krzysztof Kozlowski
2026-03-01 14:12   ` Krzysztof Kozlowski
2026-03-02  8:15     ` Alexandre TORGUE
2026-03-10  9:04     ` Alexandre TORGUE
2026-01-05 14:38 ` [PATCH v2 1/3] bus: qcom-ebi2: Simplify with scoped for each OF child loop Krzysztof Kozlowski
2026-01-06 17:52 ` (subset) " Bjorn Andersson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fe8bdea9-4bd2-4200-8b7c-3c231dc6dcb2@foss.st.com \
    --to=gatien.chevallier@foss.st.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andersson@kernel.org \
    --cc=jonathan.cameron@huawei.com \
    --cc=konradybcio@kernel.org \
    --cc=krzysztof.kozlowski@oss.qualcomm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®