Re: [RFC] cdc-acm: Fix potential deadlock (lockdep warning)

From: Havard Skinnemoen
Date: Wed Nov 23 2011 - 16:08:35 EST


On Wed, Nov 23, 2011 at 11:55 AM, Jiri Slaby <jslaby@xxxxxxx> wrote:
> On 11/23/2011 07:53 PM, Havard Skinnemoen wrote:
>> --- a/drivers/usb/class/cdc-acm.c
>> +++ b/drivers/usb/class/cdc-acm.c
> ...
>> @@ -567,19 +574,10 @@ static void acm_tty_close(struct tty_struct *tty, struct file *filp)
>>
>>       /* Perform the closing process and see if we need to do the hardware
>>          shutdown */
>> -     if (!acm)
>> -             return;
>> -
>> -     mutex_lock(&open_mutex);
>>       if (tty_port_close_start(&acm->port, tty, filp) == 0) {
>
> Note that port->count is protected by port->lock usually. Till now it
> used to be protected by open_mutex in your driver. As of now it is not
> protected by anything. (Well, BTM is still there to save you, but...)

tty_port_close_start() takes port->lock, so if we try to do that,
we'll turn a potential deadlock into a real one. Or did you mean
something else?

I think I'll try to follow Alan's advice and use tty_port_close()
instead of the split functions. it shouldn't be too hard once we get
the lifecycle issues out of the way.

Havard
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/