Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
To: Cristian Marussi <cristian.marussi@arm.com>
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, arm-scmi@vger.kernel.org,
	sudeep.holla@kernel.org, philip.radford@arm.com,
	Sashiko <sashiko-bot@kernel.org>
Subject: Re: [PATCH 1/2] firmware: arm_scmi: Invoke proper protocol cleanup on failure
Date: Tue, 24 Nov 2026 14:43:51 -0800	[thread overview]
Message-ID: <20261124144351.000034dc@oss.qualcomm.com> (raw)
In-Reply-To: <20261124185111.1022322-2-cristian.marussi@arm.com>

On Tue, 24 Nov 2026 18:51:10 +0000
Cristian Marussi <cristian.marussi@arm.com> wrote:

> After a failure in the protocol initialization phase, invoke if provided
> the protocol deinitialization routines.
> 
> Fixes: 48dc16e2e52c ("firmware: arm_scmi: Extend protocol registration interfaces")
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Closes: https://sashiko.dev/#/bug/linux-12cc0795-af8e-4d0c-8f6a-780a6728de7a
> Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>

This function is 'fun' for it's mixing of devres, reference counting
and manual cleanup.  Plus why is it responsible for the
scmi_protocol_put(proto) when the reference is grabbed in the caller?
There is no reason I can see we can't hold that reference past the calls
that follow which release a devres group but don't hold anything specific
the protocol module. 

Anyhow, far as I can tell the fix is right but if anyone has the time I'd
take a look at whether this can be simplified.
So with that slightly doubtful set of comments in mind.

Reviewed-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>

> ---
>  drivers/firmware/arm_scmi/driver.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
> index 05092301db29..2c4424aa0d37 100644
> --- a/drivers/firmware/arm_scmi/driver.c
> +++ b/drivers/firmware/arm_scmi/driver.c
> @@ -2303,7 +2303,7 @@ scmi_alloc_init_protocol_instance(struct scmi_info *info,
>  	ret = idr_alloc(&info->protocols, pi, proto->id, proto->id + 1,
>  			GFP_KERNEL);
>  	if (ret != proto->id)
> -		goto clean;
> +		goto deinit;
>  
>  	/*
>  	 * Warn but ignore events registration errors since we do not want
> @@ -2324,6 +2324,9 @@ scmi_alloc_init_protocol_instance(struct scmi_info *info,
>  
>  	return pi;
>  
> +deinit:
> +	if (pi->proto->instance_deinit)
> +		pi->proto->instance_deinit(&pi->ph);
>  clean:
>  	/* Take care to put the protocol module's owner before releasing all */
>  	scmi_protocol_put(proto);



  reply	other threads:[~2026-11-24 22:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 18:51 [PATCH 0/2] SCMI protocols fixes and refactor Cristian Marussi
2026-11-24 18:51 ` [PATCH 1/2] firmware: arm_scmi: Invoke proper protocol cleanup on failure Cristian Marussi
2026-11-24 22:43   ` Jonathan Cameron [this message]
2026-11-24 18:51 ` [PATCH 2/2] firmware: arm_scmi: Refactor protocol allocation Cristian Marussi

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=20261124144351.000034dc@oss.qualcomm.com \
    --to=jonathan.cameron@oss.qualcomm.com \
    --cc=arm-scmi@vger.kernel.org \
    --cc=cristian.marussi@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=philip.radford@arm.com \
    --cc=sashiko-bot@kernel.org \
    --cc=sudeep.holla@kernel.org \
    /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