From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7037C433F5 for ; Fri, 29 Apr 2022 15:37:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378588AbiD2Pkz (ORCPT ); Fri, 29 Apr 2022 11:40:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378570AbiD2Pky (ORCPT ); Fri, 29 Apr 2022 11:40:54 -0400 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 558D6D64F6 for ; Fri, 29 Apr 2022 08:37:33 -0700 (PDT) Received: (qmail 950759 invoked by uid 1000); 29 Apr 2022 11:37:32 -0400 Date: Fri, 29 Apr 2022 11:37:32 -0400 From: Alan Stern To: Vincent Shih Cc: gregkh@linuxfoundation.org, p.zabel@pengutronix.de, davem@davemloft.net, vladimir.oltean@nxp.com, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, devicetree@vger.kernel.org, wells.lu@sunplus.com Subject: Re: [PATCH v4 1/2] usb: host: ehci-sunplus: Add driver for ehci in Sunplus SP7021 Message-ID: References: <1651220876-26705-1-git-send-email-vincent.sunplus@gmail.com> <1651220876-26705-2-git-send-email-vincent.sunplus@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1651220876-26705-2-git-send-email-vincent.sunplus@gmail.com> Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 > --- > 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