Chrome platform driver development
 help / color / mirror / Atom feed
From: Javier Carrasco <javier.carrasco.cruz@gmail.com>
To: Prashant Malani <pmalani@chromium.org>,
	Benson Leung <bleung@chromium.org>,
	Tzung-Bi Shih <tzungbi@kernel.org>,
	Guenter Roeck <groeck@chromium.org>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Enric Balletbo i Serra <eballetbo@kernel.org>
Cc: chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] platform/chrome: cross_ec_type: fix missing fwnode reference decrement
Date: Wed, 9 Oct 2024 21:00:41 +0200	[thread overview]
Message-ID: <7767afd2-0ada-4cca-8861-ccdc874d555b@gmail.com> (raw)
In-Reply-To: <20241009-cross_ec_typec_fwnode_handle_put-v1-1-f17bdb48d780@gmail.com>

On 09/10/2024 20:55, Javier Carrasco wrote:
> The device_for_each_child_node() macro requires explicit calls to
> fwnode_handle_put() upon early exits (return, break, goto) to decrement
> the fwnode's refcount, and avoid levaing a node reference behind.
> 
> Add the missing fwnode_handle_put() after the common label for all error
> paths.
> 
> Cc: stable@vger.kernel.org
> Fixes: fdc6b21e2444 ("platform/chrome: Add Type C connector class driver")
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
> ---
> I usually switch to the scoped variant of the macro to fix such issues,
> but given that the fix is relevant for stable kernels, I have provided
> the "classical" approach by adding the missing fwnode_handle_put().
> 
> If switching to the scoped variant is desired, please let me know.
> This driver and cross_typec_switch could be easily converted.
> 
> By the way, I wonder why all error paths are redirected to the same
> label to unregister ports, even before registering them (which seems to
> be harmless because unregistered ports are ignored, but still). With this
> fix, that jump to the label is definitely required, but if the scoped
> variant is used, maybe some simple returns would be enough.
> ---
>  drivers/platform/chrome/cros_ec_typec.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> index c7781aea0b88..f1324466efac 100644
> --- a/drivers/platform/chrome/cros_ec_typec.c
> +++ b/drivers/platform/chrome/cros_ec_typec.c
> @@ -409,6 +409,7 @@ static int cros_typec_init_ports(struct cros_typec_data *typec)
>  	return 0;
>  
>  unregister_ports:
> +	fwnode_handle_put(fwnode);
>  	cros_unregister_ports(typec);
>  	return ret;
>  }
> 
> ---
> base-commit: b6270c3bca987530eafc6a15f9d54ecd0033e0e3
> change-id: 20241009-cross_ec_typec_fwnode_handle_put-9f13b4bd467f
> 
> Best regards,

Small typo in the description, should be cross_ec_typec (last c is
missing). I will fix that for v2, but I will wait for feedback and
reviews to this first version.

Best regards,
Javier Carrasco

  reply	other threads:[~2024-10-09 19:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-09 18:55 [PATCH] platform/chrome: cross_ec_type: fix missing fwnode reference decrement Javier Carrasco
2024-10-09 19:00 ` Javier Carrasco [this message]
2024-10-11  3:17   ` Tzung-Bi Shih

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=7767afd2-0ada-4cca-8861-ccdc874d555b@gmail.com \
    --to=javier.carrasco.cruz@gmail.com \
    --cc=bleung@chromium.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=eballetbo@kernel.org \
    --cc=groeck@chromium.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmalani@chromium.org \
    --cc=stable@vger.kernel.org \
    --cc=tzungbi@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