mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
scsi: scsi_debug: Fix a locking bug in resp_write_same()
If fetch_to_dev_buffer() fails in resp_write_same(), the function jumps
to 'out' without releasing the data write lock acquired earlier via
sdeb_data_write_lock(). Jump to 'unlock' instead so that
sdeb_data_write_unlock() is called on the error path. This bug has been
discovered by building the scsi_debug driver with Clang and modified
lock context annotations. The modified lock context annotations are
available in patch "scsi: scsi_debug: Improve lock context annotations".
Fixes: 84f3a3c01d ("scsi: scsi_debug: Atomic write support")
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: John Garry <john.garry@linux.dev>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://patch.msgid.link/271ea11d3bc147d950a89419181f0c3f5a1ebf3b.1791924924.git.bvanassche@acm.org
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
This commit is contained in:
parent
2f4880c22e
commit
2f50ca3d46
|
|
@ -5455,7 +5455,7 @@ static int resp_write_same(struct scsi_cmnd *scp, u64 lba, u32 num,
|
|||
|
||||
if (-1 == ret) {
|
||||
ret = DID_ERROR << 16;
|
||||
goto out;
|
||||
goto unlock;
|
||||
} else if (sdebug_verbose && !ndob && (ret < lb_size))
|
||||
sdev_printk(KERN_INFO, scp->device,
|
||||
"%s: %s: lb size=%u, IO sent=%d bytes\n",
|
||||
|
|
@ -5472,8 +5472,9 @@ static int resp_write_same(struct scsi_cmnd *scp, u64 lba, u32 num,
|
|||
/* If ZBC zone then bump its write pointer */
|
||||
if (sdebug_dev_is_zoned(devip))
|
||||
zbc_inc_wp(devip, lba, num);
|
||||
sdeb_data_write_unlock(sip);
|
||||
ret = 0;
|
||||
unlock:
|
||||
sdeb_data_write_unlock(sip);
|
||||
out:
|
||||
if (meta_data_locked)
|
||||
sdeb_meta_write_unlock(sip);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user