[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZCK4uZCrbVZ/HfRq@hovoldconsulting.com>
Date: Tue, 28 Mar 2023 11:51:53 +0200
From: Johan Hovold <johan@...nel.org>
To: Manivannan Sadhasivam <manivannan.sadhasivam@...aro.org>
Cc: andersson@...nel.org, Thinh.Nguyen@...opsys.com,
gregkh@...uxfoundation.org, mathias.nyman@...el.com,
konrad.dybcio@...aro.org, robh+dt@...nel.org,
krzysztof.kozlowski+dt@...aro.org, linux-arm-msm@...r.kernel.org,
linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
devicetree@...r.kernel.org
Subject: Re: [PATCH 3/5] usb: dwc3: qcom: Fix null ptr access during
runtime_suspend()
On Tue, Mar 28, 2023 at 03:17:18PM +0530, Manivannan Sadhasivam wrote:
> On Tue, Mar 28, 2023 at 11:23:32AM +0200, Johan Hovold wrote:
> > On Sat, Mar 25, 2023 at 10:22:15PM +0530, Manivannan Sadhasivam wrote:
> > > static int dwc3_qcom_suspend(struct dwc3_qcom *qcom, bool wakeup)
> > > {
> > > + struct dwc3 *dwc = platform_get_drvdata(qcom->dwc3);
> > > u32 val;
> > > int i, ret;
> > >
> > > - if (qcom->is_suspended)
> > > + if (qcom->is_suspended || !dwc)
> > > return 0;
> >
> > I think we should try to keep the layering violations confined to the
> > helper functions. So how about amending dwc3_qcom_is_host() and check
> > for NULL before dereferencing the xhci pointer?
> >
> > If the dwc3 driver hasn't probed yet, we're clearly not in host mode
> > either...
>
> Well, that's what I initially did but then I reverted to this approach as
> returning true/false from dwc3_qcom_is_host() based on the pointer availability
> doesn't sound right.
>
> For example, if we return true then it implies that the driver is in host mode
> which is logically wrong (before dwc3 probe) even though there is no impact.
No, you should return false of course as we are *not* in host mode as I
mentioned above.
Johan
Powered by blists - more mailing lists