Re: Mutex deadlock from garmin_close in garmin_gps.c

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

 



2009/4/6 Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>:
> On Mon, 6 Apr 2009, Ming Lei wrote:
>
>> 2009/4/5 Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>:
>> >
>> > BTW, I'm concerned about that usb-serial.c patch posted earlier.  In
>>
>> what is the purpose of the patch? which fixes?
>
> The purpose of the patch is to fix the bug reported here:
>
>        http://bugs.freedesktop.org/show_bug.cgi?id=20703
>
> The bug is that the usb_serial and usb_serial_port structures are not
> reference-counted correctly.
>
>> > particular, does serial_open() hold disc_mutex long enough?  What
>>
>> IMHO, it is not a kind of open/disconnect race, serial_port_open() is more
>> proper than serial_open().
>
> What are you talking about?  There is no serial_port_open() routine in
> drivers/usb/serial, nor anywhere else I know of.

I mean that maybe the name of serial_port_open is more proper , after all
it is used to open a usb serial port, not a usb serial, but the
disconnect event is
received by usb_serial, instead of usb_serial_port.

>
>>  Once usb_serial_get_by_index() returns a non NULL
>> serial, the port device doesn't disappear even if the usb serial
>> device is disconnected.
>
> First of all, this doesn't make sense.  usb_serial_get_by_index()
> returns a pointer to the usb_serial structure, not to the port device.
> So the usb_serial structure won't disappear, but there's nothing to
> prevent the usb_serial_port structure from disappearing.

usb_serial_port structure is freed  in destroy_serial(), which is only called if
the reference count of usb_serial is zero.

>
> Second, none of this matters since I'm not concerned about whether the
> port device disappears.  Rather, I'm concerned about whether
> serial_open() can call usb_autopm_get_interface() after
> usb_serial_disconnect() has returned.  That should never happen.

If usb_serial_disconnect() has returned, usb_autopm_get_interface() may
return a failure, and serial_open can process the case.

>
>> So, maybe holding disc_mutex in serial_open is not necessary.
>>
>> > happens if a disconnect occurs while serial_open() is waiting to
>> > acquire port->mutex?  Do you think the calls to
>>
>> mutex_lock_interruptible() should return a failed value.
>
> Why shoult it?  The only reason mutex_lock_interruptible() ever returns
> a failure is if the task gets interrupted (for example, the user
> presses ^C).

I guess it is the tty_hangup( called by usb_serial_disconnect),which can
cause mutex_lock_interruptible() to return a failure.

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