Message ID | 20200904200554.168979-4-tom.ty89@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [1/4] scsi: sg: fix BLKSECTGET ioctl | expand |
On 2020-09-04 4:05 p.m., Tom Yan wrote: > Signed-off-by: Tom Yan <tom.ty89@gmail.com> Reviewed-by: Douglas Gilbert <dgilbert@interlog.com> > --- > block/scsi_ioctl.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c > index ef722f04f88a..ae6aae40a8b6 100644 > --- a/block/scsi_ioctl.c > +++ b/block/scsi_ioctl.c > @@ -73,10 +73,11 @@ static int sg_set_timeout(struct request_queue *q, int __user *p) > static int max_sectors_bytes(struct request_queue *q) > { > unsigned int max_sectors = queue_max_sectors(q); > + unsigned int logical_block_size = queue_logical_block_size(q); > > - max_sectors = min_t(unsigned int, max_sectors, INT_MAX >> 9); > + max_sectors = min_t(unsigned int, max_sectors, USHRT_MAX); > > - return max_sectors << 9; > + return max_sectors * logical_block_size; > } > > static int sg_get_reserved_size(struct request_queue *q, int __user *p) >
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c index ef722f04f88a..ae6aae40a8b6 100644 --- a/block/scsi_ioctl.c +++ b/block/scsi_ioctl.c @@ -73,10 +73,11 @@ static int sg_set_timeout(struct request_queue *q, int __user *p) static int max_sectors_bytes(struct request_queue *q) { unsigned int max_sectors = queue_max_sectors(q); + unsigned int logical_block_size = queue_logical_block_size(q); - max_sectors = min_t(unsigned int, max_sectors, INT_MAX >> 9); + max_sectors = min_t(unsigned int, max_sectors, USHRT_MAX); - return max_sectors << 9; + return max_sectors * logical_block_size; } static int sg_get_reserved_size(struct request_queue *q, int __user *p)
Signed-off-by: Tom Yan <tom.ty89@gmail.com> --- block/scsi_ioctl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)