All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: xen-netback: add control protocol implementation
@ 2016-05-17 16:32 Dan Carpenter
  2016-05-17 16:49 ` Paul Durrant
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2016-05-17 16:32 UTC (permalink / raw)
  To: Paul.Durrant; +Cc: xen-devel

Hello Paul Durrant,

The patch 40d8abdee806: "xen-netback: add control protocol
implementation" from May 13, 2016, leads to the following static
checker warning:

	drivers/net/xen-netback/hash.c:362 xenvif_set_hash_mapping()
	warn: should this be 'len == -1'

drivers/net/xen-netback/hash.c
   341  u32 xenvif_set_hash_mapping(struct xenvif *vif, u32 gref, u32 len,
   342                              u32 off)
   343  {
   344          u32 *mapping = &vif->hash.mapping[off];
   345          struct gnttab_copy copy_op = {
   346                  .source.u.ref = gref,
   347                  .source.domid = vif->domid,
   348                  .dest.u.gmfn = virt_to_gfn(mapping),
   349                  .dest.domid = DOMID_SELF,
   350                  .dest.offset = xen_offset_in_page(mapping),
   351                  .len = len * sizeof(u32),
   352                  .flags = GNTCOPY_source_gref
   353          };
   354  
   355          if ((off + len > vif->hash.size) || copy_op.len > XEN_PAGE_SIZE)
   356                  return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER;
   357  
   358          while (len-- != 0)
   359                  if (mapping[off++] >= vif->num_queues)
   360                          return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER;
   361  
   362          if (len != 0) {
                    ^^^^^^^^
We know that "len" is always UINT_MAX here meaning this is always true.
What are trying to test?

   363                  gnttab_batch_copy(&copy_op, 1);
   364  
   365                  if (copy_op.status != GNTST_okay)
   366                          return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER;
   367          }
   368  
   369          return XEN_NETIF_CTRL_STATUS_SUCCESS;
   370  }

regards,
dan carpenter

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

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

* Re: xen-netback: add control protocol implementation
  2016-05-17 16:32 xen-netback: add control protocol implementation Dan Carpenter
@ 2016-05-17 16:49 ` Paul Durrant
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Durrant @ 2016-05-17 16:49 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: xen-devel@lists.xenproject.org

> -----Original Message-----
> From: Dan Carpenter [mailto:dan.carpenter@oracle.com]
> Sent: 17 May 2016 17:32
> To: Paul Durrant
> Cc: xen-devel@lists.xenproject.org
> Subject: re: xen-netback: add control protocol implementation
> 
> Hello Paul Durrant,
> 
> The patch 40d8abdee806: "xen-netback: add control protocol
> implementation" from May 13, 2016, leads to the following static
> checker warning:
> 
> 	drivers/net/xen-netback/hash.c:362 xenvif_set_hash_mapping()
> 	warn: should this be 'len == -1'
> 
> drivers/net/xen-netback/hash.c
>    341  u32 xenvif_set_hash_mapping(struct xenvif *vif, u32 gref, u32 len,
>    342                              u32 off)
>    343  {
>    344          u32 *mapping = &vif->hash.mapping[off];
>    345          struct gnttab_copy copy_op = {
>    346                  .source.u.ref = gref,
>    347                  .source.domid = vif->domid,
>    348                  .dest.u.gmfn = virt_to_gfn(mapping),
>    349                  .dest.domid = DOMID_SELF,
>    350                  .dest.offset = xen_offset_in_page(mapping),
>    351                  .len = len * sizeof(u32),
>    352                  .flags = GNTCOPY_source_gref
>    353          };
>    354
>    355          if ((off + len > vif->hash.size) || copy_op.len > XEN_PAGE_SIZE)
>    356                  return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER;
>    357
>    358          while (len-- != 0)
>    359                  if (mapping[off++] >= vif->num_queues)
>    360                          return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER;
>    361
>    362          if (len != 0) {
>                     ^^^^^^^^
> We know that "len" is always UINT_MAX here meaning this is always true.
> What are trying to test?
> 

Yes, that's clearly bogus. The test is supposed to be checking whether the copy_op actually does something so it should be:

If (copy_op.len != 0)

I'll send a patch.

  Paul

>    363                  gnttab_batch_copy(&copy_op, 1);
>    364
>    365                  if (copy_op.status != GNTST_okay)
>    366                          return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER;
>    367          }
>    368
>    369          return XEN_NETIF_CTRL_STATUS_SUCCESS;
>    370  }
> 
> regards,
> dan carpenter

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

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

end of thread, other threads:[~2016-05-17 16:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-17 16:32 xen-netback: add control protocol implementation Dan Carpenter
2016-05-17 16:49 ` Paul Durrant

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.