Re: [PATCH v4 1/2] usb: host: ehci-sunplus: Add driver for ehci in Sunplus SP7021

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

 



On Fri, Apr 29, 2022 at 04:27:55PM +0800, Vincent Shih wrote:
> Add driver for ehci in Sunplus SP7021
> 
> Signed-off-by: Vincent Shih <vincent.sunplus@xxxxxxxxx>
> ---
> Changes in v4:
>   - Implement power_on, power_off and power_suspend functions.

Did you test these?  Did you try to rmmod the ehci-sunplus module after 
adding these functions?

> diff --git a/drivers/usb/host/ehci-sunplus.c b/drivers/usb/host/ehci-sunplus.c
> new file mode 100644
> index 0000000..4d8e20d
> --- /dev/null
> +++ b/drivers/usb/host/ehci-sunplus.c
> @@ -0,0 +1,289 @@

...

> +static void sp_ehci_platform_power_off(struct platform_device *pdev)
> +{
> +	struct usb_hcd *hcd = platform_get_drvdata(pdev);
> +	struct sp_ehci_priv *sp_priv = hcd_to_sp_ehci_priv(hcd);
> +
> +	phy_power_off(sp_priv->phy);
> +	phy_exit(sp_priv->phy);

Notice that this dereferences a field contained in the sp_ehci_priv 
extension to the usb_hcd structure.

...

> +static int ehci_sunplus_remove(struct platform_device *pdev)
> +{
> +	struct usb_hcd *hcd = platform_get_drvdata(pdev);
> +	struct usb_ehci_pdata *pdata = pdev->dev.platform_data;
> +
> +	usb_remove_hcd(hcd);
> +	usb_put_hcd(hcd);

This call deallocates the usb_hcd structure.

> +
> +	if (pdata->power_off)
> +		pdata->power_off(pdev);

But here you dereference a field that it contains.  This power-off 
operation must occur _before_ the usb_put_hcd() call.

Alan Stern



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux