]> rtime.felk.cvut.cz Git - linux-imx.git/commit
firewire: core: fix race at address_handler unregistration
authorStefan Richter <stefanr@s5r6.in-berlin.de>
Sat, 18 Feb 2012 18:54:45 +0000 (19:54 +0100)
committerStefan Richter <stefanr@s5r6.in-berlin.de>
Wed, 22 Feb 2012 21:36:01 +0000 (22:36 +0100)
commit90963f1cdb3baffc68321e7c98073bf9e99d2ec7
treef05b75602a799b48d38f751de20b879d87bd6c4a
parent280f64d4f108b7ac707d6208d50a59627b984dc5
firewire: core: fix race at address_handler unregistration

Fix the following unlikely but possible race:

CPU 1                             CPU 2
------------------------------------------------------------------------
AR-request tasklet
    lookup handler
                                  unregister handler
  free handler->callback_data or handler
    call handler->callback

The application which registered the handler has no way to stop nodes
sending new requests to their address range, hence cannot prevent this
race.

Fix it simply by extending the address_handler_lock-protected region
from only around the lookup to around both lookup and call.  We only
need to do so in the exclusive region handler; the FCP region handler
already holds the lock around the handler->callback call.

Alas this removes the current ability to execute the callback in
parallel on different CPUs if it was called for different FireWire cards
at the same time.  (For a single card, the handler is already
serialized.)  If this loss of a rather obscure feature is not tolerable,
a more complex fix would be required:  Add a handler reference counter;
wait in fw_core_remove_address_handler() for this conter to become zero.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
drivers/firewire/core-transaction.c