Re: usbip: vhci extension: modifications to vhci driver

2016-10-12 Thread Dan Carpenter
On Wed, Oct 12, 2016 at 05:24:31AM +, fx IWATA NOBUO wrote:
> Hello,
> 
> I will send a patch to clear this warning.
> 
> The current behavior is as following:
> vdev_to_vhci() is inline of container_of().
> A pointer (struct vhci_hcd *vhci) may be container_of() from NULL for a
> while.
> If it is container_of() from NULL, it will not be referenced because of
>  NULL check of source pointer of the container_of().

Are you looking at linux-next?  vdev_to_vhci() derefernces "vdev" to get
vdev->rhport so this is a bug and not a false positive.

Smatch sometimes does have false positives because it thinks foo->array
is a dereference when really we're taking the address of the array.  I
should fix that...  But it understands that container_of(NULL) is ok.

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: usbip: vhci extension: modifications to vhci driver

2016-10-12 Thread fx IWATA NOBUO
Hello,

> vdev_to_vhci() derefernces "vdev" to get vdev->rhport

Yes, you are right.
Sorry about my misreading.

I'm creating the patch and will send later.

Thank you for your help,

n.iwata
//
> -Original Message-
> From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
> Sent: Wednesday, October 12, 2016 5:57 PM
> To: fx IWATA NOBUO
> Cc: linux-usb@vger.kernel.org
> Subject: Re: usbip: vhci extension: modifications to vhci driver
> 
> On Wed, Oct 12, 2016 at 05:24:31AM +, fx IWATA NOBUO wrote:
> > Hello,
> >
> > I will send a patch to clear this warning.
> >
> > The current behavior is as following:
> > vdev_to_vhci() is inline of container_of().
> > A pointer (struct vhci_hcd *vhci) may be container_of() from NULL for
> > a while.
> > If it is container_of() from NULL, it will not be referenced because
> > of  NULL check of source pointer of the container_of().
> 
> Are you looking at linux-next?  vdev_to_vhci() derefernces "vdev" to get
> vdev->rhport so this is a bug and not a false positive.
> 
> Smatch sometimes does have false positives because it thinks foo->array
> is a dereference when really we're taking the address of the array.  I should
> fix that...  But it understands that container_of(NULL) is ok.
> 
> regards,
> dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: usbip: vhci extension: modifications to vhci driver

2016-10-11 Thread fx IWATA NOBUO
Hello,

I will send a patch to clear this warning.

The current behavior is as following:
vdev_to_vhci() is inline of container_of().
A pointer (struct vhci_hcd *vhci) may be container_of() from NULL for a
while.
If it is container_of() from NULL, it will not be referenced because of
 NULL check of source pointer of the container_of().

Thank you,

n.iwata
//
> -Original Message-
> From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
> Sent: Tuesday, October 11, 2016 4:03 PM
> To: fx IWATA NOBUO
> Cc: linux-usb@vger.kernel.org
> Subject: re: usbip: vhci extension: modifications to vhci driver
> 
> Hello Nobuo Iwata,
> 
> This is a semi-automatic email about new static checker warnings.
> 
> The patch 0775a9cbc694: "usbip: vhci extension: modifications to vhci
> driver" from Jun 13, 2016, leads to the following Smatch complaint:
> 
> drivers/usb/usbip/vhci_hcd.c:466 vhci_tx_urb()
>warn: variable dereferenced before check 'vdev' (see line 463)
> 
> drivers/usb/usbip/vhci_hcd.c
>462struct vhci_priv *priv;
>463struct vhci_hcd *vhci = vdev_to_vhci(vdev);
> ^^ Patch adds a
> new dereference inside the vdev_to_vhci() function.
> 
>464unsigned long flags;
>465
>466if (!vdev) {
> ^
> Old code assumed "vdev" could be NULL.
> 
>467pr_err("could not get virtual device");
>468return;
> 
> regards,
> dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


re: usbip: vhci extension: modifications to vhci driver

2016-10-11 Thread Dan Carpenter
Hello Nobuo Iwata,

This is a semi-automatic email about new static checker warnings.

The patch 0775a9cbc694: "usbip: vhci extension: modifications to vhci 
driver" from Jun 13, 2016, leads to the following Smatch complaint:

drivers/usb/usbip/vhci_hcd.c:466 vhci_tx_urb()
 warn: variable dereferenced before check 'vdev' (see line 463)

drivers/usb/usbip/vhci_hcd.c
   462  struct vhci_priv *priv;
   463  struct vhci_hcd *vhci = vdev_to_vhci(vdev);
^^
Patch adds a new dereference inside the vdev_to_vhci() function.

   464  unsigned long flags;
   465  
   466  if (!vdev) {
^
Old code assumed "vdev" could be NULL.

   467  pr_err("could not get virtual device");
   468  return;

regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html