firewire: core: extend card->lock in fw_core_handle_bus_reset
authorNiels Dossche <dossche.niels@gmail.com>
Sat, 9 Apr 2022 04:12:43 +0000 (13:12 +0900)
committerTakashi Iwai <tiwai@suse.de>
Mon, 25 Apr 2022 06:01:09 +0000 (08:01 +0200)
commita7ecbe92b9243edbe94772f6f2c854e4142a3345
tree2fae7ac5c9b99acffb048c43e0612579ec166484
parent9423973869bd4632ffe669f950510c49296656e0
firewire: core: extend card->lock in fw_core_handle_bus_reset

card->local_node and card->bm_retries are both always accessed under
card->lock.
fw_core_handle_bus_reset has a check whose condition depends on
card->local_node and whose body writes to card->bm_retries.
Both of these accesses are not under card->lock. Move the lock acquiring
of card->lock to before this check such that these accesses do happen
when card->lock is held.
fw_destroy_nodes is called inside the check.
Since fw_destroy_nodes already acquires card->lock inside its function
body, move this out to the callsites of fw_destroy_nodes.
Also add a comment to indicate which locking is necessary when calling
fw_destroy_nodes.

Cc: <stable@vger.kernel.org>
Signed-off-by: Niels Dossche <dossche.niels@gmail.com>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20220409041243.603210-4-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
drivers/firewire/core-card.c
drivers/firewire/core-topology.c