* [PATCH] scsi: st: Fix lock leak in st_ioctl()
@ 2026-05-20 7:40 Hongling Zeng
2026-05-20 7:52 ` Hongling Zeng
0 siblings, 1 reply; 3+ messages in thread
From: Hongling Zeng @ 2026-05-20 7:40 UTC (permalink / raw)
To: Kai.Makisara, James.Bottomley, martin.petersen, djeffery,
jmeneghi
Cc: linux-scsi, linux-kernel, zhongling0719, Hongling Zeng
The default case in the switch statement returns directly from
st_common_ioctl() without releasing &STp->lock, causing a lock
imbalance. Fix by jumping to the out label to properly release
the lock.
Fixes: b37d70c0df85 ("scsi: st: Separate st-unique ioctl handling from SCSI common ioctl handling")
Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
---
drivers/scsi/st.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index f1c3c4946637..3b08992e1b10 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -3628,7 +3628,8 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)
case MTIOCTOP:
break;
default:
- return st_common_ioctl(STp, STm, file, cmd_in, arg);
+ retval = st_common_ioctl(STp, STm, file, cmd_in, arg);
+ goto out;
}
cmd_type = _IOC_TYPE(cmd_in);
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] scsi: st: Fix lock leak in st_ioctl()
2026-05-20 7:40 [PATCH] scsi: st: Fix lock leak in st_ioctl() Hongling Zeng
@ 2026-05-20 7:52 ` Hongling Zeng
2026-05-20 16:25 ` Bart Van Assche
0 siblings, 1 reply; 3+ messages in thread
From: Hongling Zeng @ 2026-05-20 7:52 UTC (permalink / raw)
To: Hongling Zeng, Kai.Makisara, James.Bottomley, martin.petersen,
djeffery, jmeneghi
Cc: linux-scsi, linux-kernel
Hi,
Please ignore my previous patch: [PATCH] scsi: st: Fix lock leak in
st_ioctl()
The original code is correct. st_common_ioctl() releases &STp->lock
internally, so there is no lock leak. This is a false positive.
Sorry for the noise.
Regards,
Hongling
在 2026年05月20日 15:40, Hongling Zeng 写道:
> The default case in the switch statement returns directly from
> st_common_ioctl() without releasing &STp->lock, causing a lock
> imbalance. Fix by jumping to the out label to properly release
> the lock.
>
> Fixes: b37d70c0df85 ("scsi: st: Separate st-unique ioctl handling from SCSI common ioctl handling")
> Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
> ---
> drivers/scsi/st.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
> index f1c3c4946637..3b08992e1b10 100644
> --- a/drivers/scsi/st.c
> +++ b/drivers/scsi/st.c
> @@ -3628,7 +3628,8 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)
> case MTIOCTOP:
> break;
> default:
> - return st_common_ioctl(STp, STm, file, cmd_in, arg);
> + retval = st_common_ioctl(STp, STm, file, cmd_in, arg);
> + goto out;
> }
>
> cmd_type = _IOC_TYPE(cmd_in);
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] scsi: st: Fix lock leak in st_ioctl()
2026-05-20 7:52 ` Hongling Zeng
@ 2026-05-20 16:25 ` Bart Van Assche
0 siblings, 0 replies; 3+ messages in thread
From: Bart Van Assche @ 2026-05-20 16:25 UTC (permalink / raw)
To: Hongling Zeng, Hongling Zeng, Kai.Makisara, James.Bottomley,
martin.petersen, djeffery, jmeneghi
Cc: linux-scsi, linux-kernel
On 5/20/26 12:52 AM, Hongling Zeng wrote:
> The original code is correct. st_common_ioctl() releases &STp->lock
> internally, so there is no lock leak.
Indeed. See also the annotations in drivers/scsi/st.c in this patch
series: "[PATCH 00/36] Enable lock context analysis for most SCSI drivers"
(https://lore.kernel.org/linux-scsi/20260312211636.3245119-1-bvanassche@acm.org/).
Bart.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-20 16:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-20 7:40 [PATCH] scsi: st: Fix lock leak in st_ioctl() Hongling Zeng
2026-05-20 7:52 ` Hongling Zeng
2026-05-20 16:25 ` Bart Van Assche
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox