linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	syzbot+60df062e1c41940cae0f@syzkaller.appspotmail.com
Subject: Re: [PATCH] usb: core: Unregister device on component_add() failure
Date: Wed, 09 Feb 2022 17:30:24 +0100	[thread overview]
Message-ID: <2094517.irdbgypaU6@leap> (raw)
In-Reply-To: <YgPI6RQd/9I4/51p@kuha.fi.intel.com>

On mercoled? 9 febbraio 2022 15:00:09 CET Heikki Krogerus wrote:
> On Tue, Feb 08, 2022 at 06:00:48PM +0100, Fabio M. De Francesco wrote:
> > Commit 8c67d06f3fd9 ("usb: Link the ports to the connectors they are
> > attached to") creates a link to the USB Type-C connector for every new
> > port that is added when possible. If component_add() fails,
> > usb_hub_create_port_device() prints a warning but does not unregister
> > the device and does not return errors to the callers.
> > 
> > Syzbot reported a "WARNING in component_del()".
> > 
> > Fix this issue in usb_hub_create_port_device by calling device_unregister()
> > and returning the errors from component_add().
> > 
> > Reported-by: syzbot+60df062e1c41940cae0f@syzkaller.appspotmail.com
> > Fixes: 8c67d06f3fd9 ("usb: Link the ports to the connectors they are attached to")
> > Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
> > ---
> >  drivers/usb/core/port.c | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > [...]
> >
> You didn't remove the peer links. Either remove them here separately,
> or alternatively you can also just shuffle the code so that you only
> create those links after the component_add() call:
>
> [...]
> 

Hello Heikki,

Thanks for your review and suggestion. I think that I'll use the second of the
two possible solutions (shuffle the code).

I had to spend some time to understand the code of usb_hub_create_port_device(),
component_add() and component_del(). Unfortunately, the USB core is very far from
the usual things I look at or care of. Therefore I missed that find_and_link_peer()
does some work that must be either unwound or simply postponed. I agree with you 
that the latter is the best solution.

I need some minutes to submit v2.

Again, thanks,

Fabio

> thanks,
> 
> -- 
> heikki
> 





      reply	other threads:[~2022-02-09 16:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-08 17:00 [PATCH] usb: core: Unregister device on component_add() failure Fabio M. De Francesco
2022-02-09 14:00 ` Heikki Krogerus
2022-02-09 16:30   ` Fabio M. De Francesco [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=2094517.irdbgypaU6@leap \
    --to=fmdefrancesco@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=syzbot+60df062e1c41940cae0f@syzkaller.appspotmail.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;
as well as URLs for NNTP newsgroup(s).