Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9ccfca0f authored by Lv Yunlong's avatar Lv Yunlong Committed by Greg Kroah-Hartman
Browse files

scsi: st: Fix a use after free in st_open()

[ Upstream commit c8c165dea4c8f5ad67b1240861e4f6c5395fa4ac ]

In st_open(), if STp->in_use is true, STp will be freed by
scsi_tape_put(). However, STp is still used by DEBC_printk() after. It is
better to DEBC_printk() before scsi_tape_put().

Link: https://lore.kernel.org/r/20210311064636.10522-1-lyl2019@mail.ustc.edu.cn


Acked-by: default avatarKai Mäkisara <kai.makisara@kolumbus.fi>
Signed-off-by: default avatarLv Yunlong <lyl2019@mail.ustc.edu.cn>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 97fe6ebe
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1267,8 +1267,8 @@ static int st_open(struct inode *inode, struct file *filp)
	spin_lock(&st_use_lock);
	if (STp->in_use) {
		spin_unlock(&st_use_lock);
		scsi_tape_put(STp);
		DEBC_printk(STp, "Device already in use.\n");
		scsi_tape_put(STp);
		return (-EBUSY);
	}