[SCSI] Fix refcount breakage with 'echo "1" > scan' when target already present
authorJames Bottomley <James.Bottomley@steeleye.com>
Tue, 5 Sep 2006 21:26:41 +0000 (16:26 -0500)
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>
Thu, 7 Sep 2006 15:08:43 +0000 (10:08 -0500)
commit884d25cc4fda20908fd4ef93dbb41d817984b68b
tree99a7a2a02ff76bee9c4a0620e6a90321517bba13
parent26dacd0c9b2dc1dc987c376aeee4e80691a7dd0b
[SCSI] Fix refcount breakage with 'echo "1" > scan' when target already present

Spotted by: Dan Aloni <da-xx@monatomic.org>

The problem is there's inconsistent locking semantic usage of
scsi_alloc_target().  Two callers assume the target comes back with
reference unincremented and the third assumes its incremented.  Fix by
always making the reference incremented on return.  Also fix path in
target alloc that could consistently increment the parent lock.
Finally document scsi_alloc_target() so its callers know what the
expectations are.

Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
drivers/scsi/scsi_scan.c