Message ID | 20220720025120.3226770-1-yanaijie@huawei.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | [v2] scsi: fix WARNING in scsi_alloc_sgtables | expand |
On 7/19/22 19:51, Jason Yan wrote: > When iovec_count is non-zero and dxfer_len is zero, the sg_io() just > genarated a null bio, and finally caused a warning below. To fix it, > skip generating a bio for this request if dxfer_len is zero. Reviewed-by: Bart Van Assche <bvanassche@acm.org>
On Wed, 20 Jul 2022 10:51:20 +0800, Jason Yan wrote: > As explained in SG_IO howto[1]: > > "If iovec_count is non-zero then 'dxfer_len' should be equal to the sum > of iov_len lengths. If not, the minimum of the two is the transfer > length." > > When iovec_count is non-zero and dxfer_len is zero, the sg_io() just > genarated a null bio, and finally caused a warning below. To fix it, > skip generating a bio for this request if dxfer_len is zero. > > [...] Applied to 5.19/scsi-fixes, thanks! [1/1] scsi: fix WARNING in scsi_alloc_sgtables https://git.kernel.org/mkp/scsi/c/d9a434fa0c12
diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c index a480c4d589f5..729e309e6034 100644 --- a/drivers/scsi/scsi_ioctl.c +++ b/drivers/scsi/scsi_ioctl.c @@ -450,7 +450,7 @@ static int sg_io(struct scsi_device *sdev, struct sg_io_hdr *hdr, fmode_t mode) goto out_put_request; ret = 0; - if (hdr->iovec_count) { + if (hdr->iovec_count && hdr->dxfer_len) { struct iov_iter i; struct iovec *iov = NULL;