]> bbs.cooldavid.org Git - net-next-2.6.git/commit
serial: fix wakup races in the mrst_max3110 driver
authorArjan van de Ven <arjan@linux.intel.com>
Thu, 17 Jun 2010 10:02:15 +0000 (11:02 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 10 Aug 2010 20:47:39 +0000 (13:47 -0700)
commitd6e679b474c096f1125087e789e7af8886de39d3
treeb24235a50fe8c6c7d640999abd02ce6ed5d91cad
parent68c16b4117cc746a91897d629b61e5f2af18c225
serial: fix wakup races in the mrst_max3110 driver

The mrst_max3110 driver had a set of unsafe wakeup sequences
along the following line:

if (!atomic_read(&foo)) {
  atomic_set(&foo, 1);
  wake_up(worker_thread);
}
and the worker thread would do

if (atomic_read(&foo)) {
  do_work();
  atomic_set(&foo, 0);
}

which can result in various missed wakups due to test-then-set races,
as well as due to clear-after-work instead of clear-before-work.

This patch fixes these races by using the proper bit test-and-set operations,
and by doing clear-before-work.

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/serial/mrst_max3110.c