提交 6745070e 编写于 作者: L Lv Yunlong 提交者: Yang Yingliang

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

stable inclusion
from linux-4.19.185
commit 31216d487aa054eef8be53a957cbf00233f46272

--------------------------------

[ Upstream commit c8c165de ]

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.cnAcked-by: NKai Mäkisara <kai.makisara@kolumbus.fi>
Signed-off-by: NLv Yunlong <lyl2019@mail.ustc.edu.cn>
Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 08fc2a31
......@@ -1265,8 +1265,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);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册