summaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorLv Yunlong <lyl2019@mail.ustc.edu.cn>2021-03-10 22:46:36 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-04-07 12:04:20 +0200
commit9ccfca0f00fbc8bb20a668fe7ba21f8ea3cc9199 (patch)
treea62251124589c84697101f8c2cbd05abd7ca3951 /drivers/scsi
parent97fe6ebe47a18b1be52ae16971b9ca9cdfbfbd05 (diff)
downloadlinux-stable-9ccfca0f00fbc8bb20a668fe7ba21f8ea3cc9199.tar.gz
linux-stable-9ccfca0f00fbc8bb20a668fe7ba21f8ea3cc9199.tar.bz2
linux-stable-9ccfca0f00fbc8bb20a668fe7ba21f8ea3cc9199.zip
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: Kai Mäkisara <kai.makisara@kolumbus.fi> Signed-off-by: Lv Yunlong <lyl2019@mail.ustc.edu.cn> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/st.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 088a68ab4246..3a3876091a9d 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -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);
}