All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Sergey Shtylyov <s.shtylyov@omp.ru>
Cc: Prashant Malani <pmalani@chromium.org>,
	linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
	chrome-platform@lists.linux.dev, bleung@chromium.org,
	heikki.krogerus@linux.intel.com,
	Daisuke Nojiri <dnojiri@chromium.org>,
	"Dustin L. Howett" <dustin@howett.net>,
	Guenter Roeck <groeck@chromium.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	Kees Cook <keescook@chromium.org>,
	Sebastian Reichel <sebastian.reichel@collabora.com>,
	Tzung-Bi Shih <tzungbi@kernel.org>
Subject: Re: [PATCH v3 2/9] usb: typec: Add retimer handle to port
Date: Fri, 8 Jul 2022 11:21:27 +0200	[thread overview]
Message-ID: <Ysf3F3VvmoqCFj4P@kroah.com> (raw)
In-Reply-To: <509bf6fe-4406-c577-aa70-6eb70801e375@omp.ru>

On Fri, Jul 08, 2022 at 11:46:44AM +0300, Sergey Shtylyov wrote:
> Hello!
> 
> On 7/8/22 1:20 AM, Prashant Malani wrote:
> 
> > Similar to mux and orientation switch, add a handle for registered
> > retimer to the port, so that it has handles to the various switches
> > connected to it.
> > 
> > Signed-off-by: Prashant Malani <pmalani@chromium.org>
> > ---
> > 
> > Changes since v2:
> > - No changes.
> > 
> > Changes since v1:
> > - Relinquish retimer reference during typec_release.
> > 
> >  drivers/usb/typec/class.c | 9 +++++++++
> >  drivers/usb/typec/class.h | 1 +
> >  2 files changed, 10 insertions(+)
> > 
> > diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> > index 9062836bb638..f08e32d552b4 100644
> > --- a/drivers/usb/typec/class.c
> > +++ b/drivers/usb/typec/class.c
> [...]
> > @@ -2249,6 +2251,13 @@ struct typec_port *typec_register_port(struct device *parent,
> >  		return ERR_PTR(ret);
> >  	}
> >  
> > +	port->retimer = typec_retimer_get(&port->dev);
> > +	if (IS_ERR(port->retimer)) {
> > +		ret = PTR_ERR(port->retimer);
> > +		put_device(&port->dev);
> > +		return ERR_PTR(ret);
> 
>    Why convert it to and fro, and not just return port->retimer?

That would be a use-after-free as port might now be gone.

thanks,

greg k-h

  reply	other threads:[~2022-07-08  9:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-07 22:20 [PATCH v3 0/9] Type-C switch driver and Type-C framework updates Prashant Malani
2022-07-07 22:20 ` [PATCH v3 1/9] usb: typec: Add support for retimers Prashant Malani
2022-07-08 12:38   ` Greg Kroah-Hartman
2022-07-08 17:24     ` Prashant Malani
2022-07-07 22:20 ` [PATCH v3 2/9] usb: typec: Add retimer handle to port Prashant Malani
2022-07-08  8:46   ` Sergey Shtylyov
2022-07-08  9:21     ` Greg Kroah-Hartman [this message]
2022-07-08  9:39       ` Sergey Shtylyov
2022-07-07 22:20 ` [PATCH v3 3/9] platform/chrome: Add Type-C mux set command definitions Prashant Malani
2022-07-07 22:20 ` [PATCH v3 4/9] platform/chrome: cros_typec_switch: Add switch driver Prashant Malani
2022-07-07 22:20 ` [PATCH v3 5/9] platform/chrome: cros_typec_switch: Set EC retimer Prashant Malani
2022-07-07 22:20 ` [PATCH v3 6/9] platform/chrome: cros_typec_switch: Add event check Prashant Malani
2022-07-07 22:20 ` [PATCH v3 7/9] platform/chrome: cros_typec_switch: Register mode switches Prashant Malani
2022-07-07 22:20 ` [PATCH v3 8/9] platform/chrome: cros_ec_typec: Cleanup switch handle return paths Prashant Malani
2022-07-07 22:20 ` [PATCH v3 9/9] platform/chrome: cros_ec_typec: Get retimer handle Prashant Malani

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=Ysf3F3VvmoqCFj4P@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=bleung@chromium.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=dnojiri@chromium.org \
    --cc=dustin@howett.net \
    --cc=groeck@chromium.org \
    --cc=gustavoars@kernel.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=pmalani@chromium.org \
    --cc=s.shtylyov@omp.ru \
    --cc=sebastian.reichel@collabora.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.