nvmet-fc: fix issues with targetport assoc_list list walking
authorJames Smart <jsmart2021@gmail.com>
Wed, 13 Mar 2019 17:55:03 +0000 (18:55 +0100)
committerJens Axboe <axboe@kernel.dk>
Wed, 13 Mar 2019 18:57:30 +0000 (12:57 -0600)
commit0191e7405b687339a5540c1562acdecefd70eb3f
treedcd0ca9ed79da2a9f751dee1f58df11c82604c4a
parent834d3710a093aa18c8aa88e6e1892180abadebaf
nvmet-fc: fix issues with targetport assoc_list list walking

There are two changes:

1) The logic in the __nvmet_fc_free_assoc() routine is bad. It uses
"safe" routines assuming pointers will come back valid.  However, the
intervening next structure being linked can be removed from the list and
the resulting safe pointers are bad, resulting in NULL ptrs being hit.

Correct by scheduling a work element to perform the association delete,
which can be done while under lock.

2) Prior patch that added the work element scheduling left a possible
reference on the object if the work element couldn't be scheduled.

Correct by doing the put on a failing schedule_work() call.

Signed-off-by: Nigel Kirkland <nigel.kirkland@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/nvme/target/fc.c