From: J <jhnlmn@yahoo.com>
To: Oliver Neukum <oliver@neukum.org>
Cc: Greg KH <gregkh@suse.de>,
linux-usb-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org
Subject: Re: Possible race condition in usb-serial.c
Date: Fri, 22 Dec 2006 12:51:56 -0800 (PST) [thread overview]
Message-ID: <567505.6711.qm@web32913.mail.mud.yahoo.com> (raw)
In-Reply-To: <200612222059.50652.oliver@neukum.org>
> 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
next prev parent reply other threads:[~2006-12-22 20:51 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-19 19:21 Possible race condition in usb-serial.c J
2006-12-19 20:15 ` Oliver Neukum
2006-12-19 22:33 ` J
2006-12-20 9:47 ` Oliver Neukum
2006-12-20 15:10 ` [linux-usb-devel] " Alan Stern
2006-12-20 21:02 ` Oliver Neukum
2006-12-20 19:32 ` J
2006-12-20 20:43 ` Oliver Neukum
2006-12-20 22:24 ` J
2006-12-22 18:14 ` Oliver Neukum
2006-12-22 19:08 ` J
2006-12-22 19:59 ` Oliver Neukum
2006-12-22 20:51 ` J [this message]
2006-12-20 20:43 ` Greg KH
2006-12-20 22:39 ` J
2006-12-20 22:52 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=567505.6711.qm@web32913.mail.mud.yahoo.com \
--to=jhnlmn@yahoo.com \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb-devel@lists.sourceforge.net \
--cc=oliver@neukum.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox