scsi: ch: fixup refcounting imbalance for SCSI devices
authorHannes Reinecke <hare@suse.de>
Thu, 13 Feb 2020 15:32:05 +0000 (16:32 +0100)
committerMartin K. Petersen <martin.petersen@oracle.com>
Mon, 24 Feb 2020 19:54:24 +0000 (14:54 -0500)
commit66167283c21ef8ce35253397108263bdab258992
treec8165e7f672be42e2c67d4b1f2c6b5bc7b5d0ee0
parent1939295a8dfa7be1cea478d6d7d283c091b780d4
scsi: ch: fixup refcounting imbalance for SCSI devices

The SCSI device is required to be present during ch_probe() and ch_open().
But the SCSI device itself is only checked during ch_open(), so it's anyones
guess if it had been present during ch_probe(). And consequently we can't
reliably detach it during ch_release(), as ch_remove() might have been
called first.  So initialize the changer device during ch_probe(), and take
a reference to the SCSI device during both ch_probe() and ch_open().

[mkp: fixed checkpatch warning]

Link: https://lore.kernel.org/r/20200213153207.123357-2-hare@suse.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/ch.c