Re: [PATCH] Fix open/close race in saa7134

From: Arjan van de Ven
Date: Mon Jun 23 2008 - 15:54:10 EST


On Mon, 23 Jun 2008 21:22:03 +0200
Marcin Slusarz <marcin.slusarz@xxxxxxxxx> wrote:

>
> If dev->empress_users could be > 1 then ok - it could break, but it
> can only be 1 or 0. If it's 1 you won't open the device. If it's 0
> you won't reach ts_close.
>
> If you still see the race, please show me the sequence, because I
> don't (of course when decrementing is the last operation of ts_close).

a decrement in C, without locking, is NOT atomic.
It in fact is
"load variable into register"
"increment register value"
"write register to variable"

which the compiler then takes and orders for maximum performance....



--
If you want to reach me at my work email, use arjan@xxxxxxxxxxxxxxx
For development, discussion and tips for power savings,
visit http://www.lesswatts.org
--
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/