Re: [PATCH] Driver core: fix race in dev_driver_string

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

 



On Fri, 4 Dec 2009, Oliver Neukum wrote:

> Am Freitag, 4. Dezember 2009 17:06:57 schrieb Alan Stern:
> > Oliver:
> > 
> > We don't have to worry about the device structure being deallocated 
> > while the routine is running.  If that happens it's a bug in the 
> > caller: improper refcounting.
> 
> That raises two points
> 
> 1. am I supposed to get a reference just so that I can use dev_err?

You're supposed to hold a reference before using dev at all.  If the 
only use you make of dev is to call dev_err(), then yes.

That's how refcounting is meant to work.

> 2. what happens if this is a soft disconnect and the device is reconnected?
> It seems to me that you'd print the wrong driver's name.

You mean the device is unbound from driver A and then bound to driver 
B, after which a thread running in driver A calls dev_err()?  Then yes, 
the "wrong" name will be printed.

This is part of the idea behind dev_err() and friends.  They print the 
name of the currently bound driver, not the name of the calling source 
file.  That's why, for example, the name "usb-storage" shows up in a 
message printed from within usbcore rather than "hub.c".

Alan Stern

--
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