Skip to content

Commit 0bd2fbe

Browse files
YueHaibingliuw
authored andcommitted
scsi: storvsc: Fix unsigned comparison to zero
The unsigned variable sg_count is being assigned a return value from the call to scsi_dma_map() that can return -ENOMEM. Signed-off-by: YueHaibing <yuehaibing@huawei.com> Reviewed-by: Michael Kelley <mikelley@microsoft.com> Link: https://lore.kernel.org/r/20211227040311.54584-1-yuehaibing@huawei.com Signed-off-by: Wei Liu <wei.liu@kernel.org>
1 parent 2deb55d commit 0bd2fbe

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

drivers/scsi/storvsc_drv.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,7 +1753,6 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
17531753
struct hv_device *dev = host_dev->dev;
17541754
struct storvsc_cmd_request *cmd_request = scsi_cmd_priv(scmnd);
17551755
struct scatterlist *sgl;
1756-
unsigned int sg_count;
17571756
struct vmscsi_request *vm_srb;
17581757
struct vmbus_packet_mpb_array *payload;
17591758
u32 payload_sz;
@@ -1826,18 +1825,17 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
18261825
memcpy(vm_srb->cdb, scmnd->cmnd, vm_srb->cdb_length);
18271826

18281827
sgl = (struct scatterlist *)scsi_sglist(scmnd);
1829-
sg_count = scsi_sg_count(scmnd);
18301828

18311829
length = scsi_bufflen(scmnd);
18321830
payload = (struct vmbus_packet_mpb_array *)&cmd_request->mpb;
18331831
payload_sz = sizeof(cmd_request->mpb);
18341832

1835-
if (sg_count) {
1833+
if (scsi_sg_count(scmnd)) {
18361834
unsigned long offset_in_hvpg = offset_in_hvpage(sgl->offset);
18371835
unsigned int hvpg_count = HVPFN_UP(offset_in_hvpg + length);
18381836
struct scatterlist *sg;
18391837
unsigned long hvpfn, hvpfns_to_add;
1840-
int j, i = 0;
1838+
int j, i = 0, sg_count;
18411839

18421840
if (hvpg_count > MAX_PAGE_BUFFER_COUNT) {
18431841

0 commit comments

Comments
 (0)