mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Wentao Liang <vulab@iscas.ac.cn>
Cc: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
	linux-usb@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] usb: typec: Fix PD object leak in select_usb_power_delivery_store()
Date: Fri, 18 Sep 2026 11:53:00 +0200	[thread overview]
Message-ID: <aq0J_PL-T0ccaAGf@black.igk.intel.com> (raw)
In-Reply-To: <20260916170139.2085947-1-vulab@iscas.ac.cn>

On Wed, Sep 16, 2026 at 05:01:39PM +0000, Wentao Liang wrote:
> select_usb_power_delivery_store() looks up the requested USB Power
> Delivery object with usb_power_delivery_find(), which returns the
> object with a reference taken by class_find_device_by_name(). The
> reference is never dropped, neither when port->ops->pd_set() fails nor
> when it succeeds, leaking a reference to the USB PD object on every
> sysfs store.
> 
> Drop the reference with put_device() once the pd_set() callback has
> returned and the object is no longer needed.
> 
> Fixes: a7cff92f0635 ("usb: typec: USB Power Delivery helpers for ports and partners")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>

There seems to already be a fix for this:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=43ae2f90b70cda374c487c1639a01d0f14e5d583

Thanks,

> ---
>  drivers/usb/typec/class.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> index 0977581ad1b6..0595e8cb83aa 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -1619,6 +1619,7 @@ static ssize_t select_usb_power_delivery_store(struct device *dev,
>  		return -EINVAL;
>  
>  	ret = port->ops->pd_set(port, pd);
> +	put_device(&pd->dev);
>  	if (ret)
>  		return ret;
>  
> -- 
> 2.34.1

-- 
heikki

      reply	other threads:[~2026-09-18  9:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-16 17:01 Wentao Liang
2026-09-18  9:53 ` Heikki Krogerus [this message]

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=aq0J_PL-T0ccaAGf@black.igk.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=vulab@iscas.ac.cn \
    /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®