Re: [PATCH 1/1] usb: host: ehci-spear: Fix potential NULL pointer dereferencing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 22 May 2013, Sachin Kamat wrote:

> 'hcd' is dereferenced before NULL check. Move the assignment after
> the check to avoid potential NULL pointer dereferencing error.

Since the pointer in question can never be NULL, you should remove the 
check entirely instead of moving the reference.

Furthermore, the reference you are moving is not a dereference, so it 
won't cause a problem even if the pointer is NULL.

> diff --git a/drivers/usb/host/ehci-spear.c b/drivers/usb/host/ehci-spear.c
> index f5ac4e2..326bfea 100644
> --- a/drivers/usb/host/ehci-spear.c
> +++ b/drivers/usb/host/ehci-spear.c
> @@ -146,10 +146,13 @@ fail:
>  static int spear_ehci_hcd_drv_remove(struct platform_device *pdev)
>  {
>  	struct usb_hcd *hcd = platform_get_drvdata(pdev);
> -	struct spear_ehci *sehci = to_spear_ehci(hcd);
> +	struct spear_ehci *sehci;
>  
>  	if (!hcd)
>  		return 0;
> +
> +	sehci = to_spear_ehci(hcd);
> +
>  	if (in_interrupt())
>  		BUG();

You can remove this test also.  This routine will never be called 
in_interrupt.

>  	usb_remove_hcd(hcd);

Alan Stern

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




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux