All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 -next] scsi: storvsc: Fix unsigned comparison to zero
@ 2021-12-27  4:03 YueHaibing
  2021-12-28 18:04 ` Michael Kelley (LINUX)
  2022-01-05  5:41 ` Martin K. Petersen
  0 siblings, 2 replies; 4+ messages in thread
From: YueHaibing @ 2021-12-27  4:03 UTC (permalink / raw)
  To: kys, haiyangz, sthemmin, wei.liu, decui, jejb, martin.petersen,
	mikelley, Tianyu.Lan, longli
  Cc: linux-hyperv, linux-scsi, linux-kernel, YueHaibing

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>
---
v2: define sg_count as int type
---
 drivers/scsi/storvsc_drv.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index ae293600d799..2273b843d9d2 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -1753,7 +1753,6 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
 	struct hv_device *dev = host_dev->dev;
 	struct storvsc_cmd_request *cmd_request = scsi_cmd_priv(scmnd);
 	struct scatterlist *sgl;
-	unsigned int sg_count;
 	struct vmscsi_request *vm_srb;
 	struct vmbus_packet_mpb_array  *payload;
 	u32 payload_sz;
@@ -1826,18 +1825,17 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
 	memcpy(vm_srb->cdb, scmnd->cmnd, vm_srb->cdb_length);
 
 	sgl = (struct scatterlist *)scsi_sglist(scmnd);
-	sg_count = scsi_sg_count(scmnd);
 
 	length = scsi_bufflen(scmnd);
 	payload = (struct vmbus_packet_mpb_array *)&cmd_request->mpb;
 	payload_sz = sizeof(cmd_request->mpb);
 
-	if (sg_count) {
+	if (scsi_sg_count(scmnd)) {
 		unsigned long offset_in_hvpg = offset_in_hvpage(sgl->offset);
 		unsigned int hvpg_count = HVPFN_UP(offset_in_hvpg + length);
 		struct scatterlist *sg;
 		unsigned long hvpfn, hvpfns_to_add;
-		int j, i = 0;
+		int j, i = 0, sg_count;
 
 		if (hvpg_count > MAX_PAGE_BUFFER_COUNT) {
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [PATCH v2 -next] scsi: storvsc: Fix unsigned comparison to zero
  2021-12-27  4:03 [PATCH v2 -next] scsi: storvsc: Fix unsigned comparison to zero YueHaibing
@ 2021-12-28 18:04 ` Michael Kelley (LINUX)
  2022-01-05  5:41 ` Martin K. Petersen
  1 sibling, 0 replies; 4+ messages in thread
From: Michael Kelley (LINUX) @ 2021-12-28 18:04 UTC (permalink / raw)
  To: YueHaibing, KY Srinivasan, Haiyang Zhang, Stephen Hemminger,
	wei.liu, Dexuan Cui, jejb, martin.petersen, Tianyu Lan, Long Li
  Cc: linux-hyperv, linux-scsi, linux-kernel

From: YueHaibing <yuehaibing@huawei.com> Sent: Sunday, December 26, 2021 8:03 PM
> 
> 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>
> ---
> v2: define sg_count as int type
> ---
>  drivers/scsi/storvsc_drv.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
> index ae293600d799..2273b843d9d2 100644
> --- a/drivers/scsi/storvsc_drv.c
> +++ b/drivers/scsi/storvsc_drv.c
> @@ -1753,7 +1753,6 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
>  	struct hv_device *dev = host_dev->dev;
>  	struct storvsc_cmd_request *cmd_request = scsi_cmd_priv(scmnd);
>  	struct scatterlist *sgl;
> -	unsigned int sg_count;
>  	struct vmscsi_request *vm_srb;
>  	struct vmbus_packet_mpb_array  *payload;
>  	u32 payload_sz;
> @@ -1826,18 +1825,17 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
>  	memcpy(vm_srb->cdb, scmnd->cmnd, vm_srb->cdb_length);
> 
>  	sgl = (struct scatterlist *)scsi_sglist(scmnd);
> -	sg_count = scsi_sg_count(scmnd);
> 
>  	length = scsi_bufflen(scmnd);
>  	payload = (struct vmbus_packet_mpb_array *)&cmd_request->mpb;
>  	payload_sz = sizeof(cmd_request->mpb);
> 
> -	if (sg_count) {
> +	if (scsi_sg_count(scmnd)) {
>  		unsigned long offset_in_hvpg = offset_in_hvpage(sgl->offset);
>  		unsigned int hvpg_count = HVPFN_UP(offset_in_hvpg + length);
>  		struct scatterlist *sg;
>  		unsigned long hvpfn, hvpfns_to_add;
> -		int j, i = 0;
> +		int j, i = 0, sg_count;
> 
>  		if (hvpg_count > MAX_PAGE_BUFFER_COUNT) {
> 
> --
> 2.17.1

Reviewed-by: Michael Kelley <mikelley@microsoft.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 -next] scsi: storvsc: Fix unsigned comparison to zero
  2021-12-27  4:03 [PATCH v2 -next] scsi: storvsc: Fix unsigned comparison to zero YueHaibing
  2021-12-28 18:04 ` Michael Kelley (LINUX)
@ 2022-01-05  5:41 ` Martin K. Petersen
  2022-01-05 12:23   ` Wei Liu
  1 sibling, 1 reply; 4+ messages in thread
From: Martin K. Petersen @ 2022-01-05  5:41 UTC (permalink / raw)
  To: YueHaibing
  Cc: kys, haiyangz, sthemmin, wei.liu, decui, jejb, martin.petersen,
	mikelley, Tianyu.Lan, longli, linux-hyperv, linux-scsi,
	linux-kernel


YueHaibing,

> 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")

This should probably go through the Hyper-V tree - I presume that's
where the offending commit is sitting?

Otherwise I can take this after -rc1 is out.

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 -next] scsi: storvsc: Fix unsigned comparison to zero
  2022-01-05  5:41 ` Martin K. Petersen
@ 2022-01-05 12:23   ` Wei Liu
  0 siblings, 0 replies; 4+ messages in thread
From: Wei Liu @ 2022-01-05 12:23 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: YueHaibing, kys, haiyangz, sthemmin, wei.liu, decui, jejb,
	mikelley, Tianyu.Lan, longli, linux-hyperv, linux-scsi,
	linux-kernel

On Wed, Jan 05, 2022 at 12:41:31AM -0500, Martin K. Petersen wrote:
> 
> YueHaibing,
> 
> > 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")
> 
> This should probably go through the Hyper-V tree - I presume that's
> where the offending commit is sitting?

Hi Martin

I will pick this up.

Thanks,
Wei.

> 
> Otherwise I can take this after -rc1 is out.
> 
> -- 
> Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-01-05 12:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-27  4:03 [PATCH v2 -next] scsi: storvsc: Fix unsigned comparison to zero YueHaibing
2021-12-28 18:04 ` Michael Kelley (LINUX)
2022-01-05  5:41 ` Martin K. Petersen
2022-01-05 12:23   ` Wei Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.