linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: YueHaibing <yuehaibing@huawei.com>
To: "Michael Kelley (LINUX)" <mikelley@microsoft.com>,
	KY Srinivasan <kys@microsoft.com>,
	Haiyang Zhang <haiyangz@microsoft.com>,
	Stephen Hemminger <sthemmin@microsoft.com>,
	"wei.liu@kernel.org" <wei.liu@kernel.org>,
	Dexuan Cui <decui@microsoft.com>,
	"jejb@linux.ibm.com" <jejb@linux.ibm.com>,
	"martin.petersen@oracle.com" <martin.petersen@oracle.com>,
	Tianyu Lan <Tianyu.Lan@microsoft.com>,
	Long Li <longli@microsoft.com>
Cc: "linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
	"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH -next] scsi: storvsc: Fix unsigned comparison to zero
Date: Mon, 27 Dec 2021 12:04:30 +0800	[thread overview]
Message-ID: <eae60bf8-98b0-254c-8191-553f68850f2f@huawei.com> (raw)
In-Reply-To: <MWHPR21MB15936A0B092F7467CC18B3C1D7419@MWHPR21MB1593.namprd21.prod.outlook.com>

On 2021/12/27 3:49, Michael Kelley (LINUX) wrote:
> From: YueHaibing <yuehaibing@huawei.com> Sent: Friday, December 24, 2021 4:02 AM
>>
>> The unsigned variable sg_count is being assigned a return value
>> from the call to scsi_dma_map() that can return -ENOMEM.
>>
>> Fixes: 743b237c3a7b ("scsi: storvsc: Add Isolation VM support for storvsc driver")
>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> 
> Good catch!  But I wonder if a simpler fix is to just remove the "unsigned"
> from the declaration of sg_count.  Then we don't need to add the
> sg_cnt local variable.  A little less complexity is almost always better. :-)

Ok, will respine
> 
> Michael
> 
>> ---
>>  drivers/scsi/storvsc_drv.c | 8 ++++----
>>  1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
>> index ae293600d799..072c752a8c36 100644
>> --- a/drivers/scsi/storvsc_drv.c
>> +++ b/drivers/scsi/storvsc_drv.c
>> @@ -1837,7 +1837,7 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
>>  		unsigned int hvpg_count = HVPFN_UP(offset_in_hvpg + length);
>>  		struct scatterlist *sg;
>>  		unsigned long hvpfn, hvpfns_to_add;
>> -		int j, i = 0;
>> +		int sg_cnt, j, i = 0;
>>
>>  		if (hvpg_count > MAX_PAGE_BUFFER_COUNT) {
>>
>> @@ -1851,11 +1851,11 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
>>  		payload->range.len = length;
>>  		payload->range.offset = offset_in_hvpg;
>>
>> -		sg_count = scsi_dma_map(scmnd);
>> -		if (sg_count < 0)
>> +		sg_cnt = scsi_dma_map(scmnd);
>> +		if (sg_cnt < 0)
>>  			return SCSI_MLQUEUE_DEVICE_BUSY;
>>
>> -		for_each_sg(sgl, sg, sg_count, j) {
>> +		for_each_sg(sgl, sg, sg_cnt, j) {
>>  			/*
>>  			 * Init values for the current sgl entry. hvpfns_to_add
>>  			 * is in units of Hyper-V size pages. Handling the
>> --
>> 2.17.1
> 
> .
> 

      reply	other threads:[~2021-12-27  4:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-24 12:02 [PATCH -next] scsi: storvsc: Fix unsigned comparison to zero YueHaibing
2021-12-26 19:49 ` Michael Kelley (LINUX)
2021-12-27  4:04   ` YueHaibing [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=eae60bf8-98b0-254c-8191-553f68850f2f@huawei.com \
    --to=yuehaibing@huawei.com \
    --cc=Tianyu.Lan@microsoft.com \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=jejb@linux.ibm.com \
    --cc=kys@microsoft.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=longli@microsoft.com \
    --cc=martin.petersen@oracle.com \
    --cc=mikelley@microsoft.com \
    --cc=sthemmin@microsoft.com \
    --cc=wei.liu@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).