Re: [PATCH] usb: host: tegra: fix potential NULL pointer dereference

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

 



On Thu, 1 Nov 2012, Wei Yongjun wrote:

> From: Wei Yongjun <yongjun_wei@xxxxxxxxxxxxxxxxx>
> 
> The dereference should be moved below the NULL test.
> 
> dpatch engine is used to auto generate this patch.
> (https://github.com/weiyj/dpatch)
> 
> Signed-off-by: Wei Yongjun <yongjun_wei@xxxxxxxxxxxxxxxxx>
> ---
>  drivers/usb/host/ehci-tegra.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
> index 6223d17..e40fcb0 100644
> --- a/drivers/usb/host/ehci-tegra.c
> +++ b/drivers/usb/host/ehci-tegra.c
> @@ -776,9 +776,13 @@ fail_clk:
>  static int tegra_ehci_remove(struct platform_device *pdev)
>  {
>  	struct tegra_ehci_hcd *tegra = platform_get_drvdata(pdev);
> -	struct usb_hcd *hcd = ehci_to_hcd(tegra->ehci);
> +	struct usb_hcd *hcd;
> +
> +	if (tegra == NULL)
> +		return -EINVAL;
>  
> -	if (tegra == NULL || hcd == NULL)
> +	hcd = ehci_to_hcd(tegra->ehci);
> +	if (hcd == NULL)
>  		return -EINVAL;
>  
>  	pm_runtime_get_sync(&pdev->dev);

In fact it would be better to remove these tests entirely.  They should 
never trigger, and if they do then an oops is the appropriate outcome.

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