Re: [RFC PATCHv2] usb: USB Type-C Connector Class

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 19, 2016 at 04:48:46PM +0200, Oliver Neukum wrote:
> On Thu, 2016-05-19 at 15:44 +0300, Heikki Krogerus wrote:
> 
> > +	dev->class = &typec_class;
> > +	dev->parent = parent;
> > +	dev->type = &typec_partner_dev_type;
> > +	dev_set_name(dev, "%s-partner", dev_name(&port->dev));
> > +
> > +	ret = device_register(dev);
> > +	if (ret) {
> > +		put_device(dev);
> > +		return ret;
> > +	}
> 
> This looks like a race condition.

Really?  How?

> > +	ret = typec_register_altmodes(dev, partner->alt_modes);
> > +	if (ret) {
> > +		device_unregister(dev);
> > +		return ret;
> > +	}
> > +
> > +	/* REVISIT: Creating symlink for the port device for now. */
> > +	ret = sysfs_create_link(&port->dev.kobj, &dev->kobj, "partner");
> > +	if (ret)
> > +		dev_WARN(&port->dev, "failed to create link to %s (%d)\n",
> > +			 dev_name(dev), ret);
> 
> The attributes should be present as soon as the device is announced.

Yes, this is wrong and racy (hint, if you have to drop down to a sysfs
call within a driver, almost always something is wrong...)

thanks,

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



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux