IB/srp: Remove target from list before freeing Scsi_Host structure
authorVu Pham <vuhuong@mellanox.com>
Thu, 10 Oct 2013 11:50:29 +0000 (13:50 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 4 Dec 2013 19:05:24 +0000 (11:05 -0800)
commita3ecf3cc3ba14a603642d60af8c8e80798d1d492
tree794f5dbdf9665d4ef59e37f4c1b4c3d3d56e1e78
parent09304cda8a43b4b119d37fc1721a33325dba4205
IB/srp: Remove target from list before freeing Scsi_Host structure

commit 65d7dd2f3479ef5aec1d9ddd1481cb7851c11af6 upstream.

Remove an SRP target from the SRP target list before invoking the last
scsi_host_put() call.  This change is necessary because that last put
frees the memory that holds the srp_target_port structure.

This patch prevents the following kernel oops:

    RIP: 0010:[<ffffffff810b00d0>] __lock_acquire+0x500/0x1570
    Call Trace:
     [<ffffffff810b11e4>] lock_acquire+0xa4/0x120
     [<ffffffff81531206>] _spin_lock+0x36/0x70
     [<ffffffffa01b6d8f>] srp_remove_work+0xef/0x180 [ib_srp]
     [<ffffffff8109125c>] worker_thread+0x21c/0x3d0
     [<ffffffff81096e86>] kthread+0x96/0xa0
     [<ffffffff8100c20a>] child_rip+0xa/0x20

Signed-off-by: Vu Pham <vuhuong@mellanox.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[ bvanassche - Modified path description and CC'ed stable. ]

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Roland Dreier <roland@purestorage.com>
drivers/infiniband/ulp/srp/ib_srp.c