don't reference freed command in scsi_init_sgtable
authorChristoph Hellwig <hch@lst.de>
Tue, 15 Apr 2014 10:24:55 +0000 (12:24 +0200)
committerJens Axboe <axboe@fb.com>
Thu, 2 Apr 2015 18:12:26 +0000 (12:12 -0600)
commit70fa269fa849e7c6042f6f9399df3748846bb658
treed1250e2bc4100a9ef5e89d30a27f03683cd093e4
parente66f634db1cdec739f79ee21fe1575b9713390ad
don't reference freed command in scsi_init_sgtable

Patch

commit 0479633686d370303e3430256ace4bd5f7f138dc
Author: Christoph Hellwig <hch@infradead.org>
Date:   Thu Feb 20 14:20:55 2014 -0800

    [SCSI] do not manipulate device reference counts in scsi_get/put_command

Introduced a use after free: when scsi_init_io fails we have to release our
device reference, but we do this trying to reference the just freed command.
Add a local scsi_device pointer to fix this.

Fixes: 0479633686d370303e3430256ace4bd5f7f138dc
Reported-by: Sander Eikelenboom <linux@eikelenboom.it>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
drivers/scsi/scsi_lib.c