[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <567505.6711.qm@web32913.mail.mud.yahoo.com>
Date: Fri, 22 Dec 2006 12:51:56 -0800 (PST)
From: J <jhnlmn@...oo.com>
To: Oliver Neukum <oliver@...kum.org>
Cc: Greg KH <gregkh@...e.de>, linux-usb-devel@...ts.sourceforge.net,
linux-kernel@...r.kernel.org
Subject: Re: Possible race condition in usb-serial.c
> No, this is a fundamental problem. You don't
> refcount
> a pointer, you refcount a data structure.
> But this is insufficient. We need to make
> sure the pointer points to valid memory.
I understand. But a typical definition of ref-count
requires the count in the data structure to be
equal to the number of outstanding pointers to this
data structure.
Every time we create a new pointer, the ref count
should be incremented. When pointer is erased, count
is decremented.
This is what I meant as "ref counting a pointer".
If we follow this rule, then each pointer will
always point to a valid memory.
So, if we apply ref counting rules consistently,
then each pointer in serial_table should be
ref counted. This will completely break the current
code, which erases serial_table from destroy_serial,
which is called only when the ref count goes to 0,
which will never happen if serial_table is ref
counted.
However, this can be fixed if usb_serial_disconnect
will erase pointers in serial_table before
calling usb_serial_put.
Now, I am not yet 100% convinced that ref counting
will, indeed, work. Atomics are known to have
problems on SMP CPUs, which can reorder operations.
But I would not discard atomics yet.
Global mutex is go ugly.
John
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists