On Thu, 6 Feb 2014, Alan Stern wrote:

> It would also be a good idea to verify that peer->peer is NULL before
> doing these assignments.

Now I see that you did this in patch 2.  Might as well do it in patch 
1 instead.

> > +   spin_lock(&peer_lock);
> > +   if (peer) {
> > +           peer->peer = NULL;
> > +           port_dev->peer = NULL;
> > +           put_device(&port_dev->dev);
> > +           put_device(&peer->dev);
> > +   }
> > +   spin_unlock(&peer_lock);
> 
> This was added in the wrong place; it should go in
> usb_port_device_release.  The way things are now, this code won't get
> executed if the device_add call fails.

Oops -- that first sentence was wrong.  If the code is moved to
usb_port_device_release then the release routine will never be called,
because of the circular references.  So it has to stay here.

This means that you have to copy this code into the failure path in 
usb_hub_create_port_device.  Or put it in a little subroutine that gets 
called from both places.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to