[PATCH v8 03/13] phy: tegra: xusb: Move usb3 port init for Tegra210
Thierry Reding
thierry.reding at gmail.com
Wed Mar 31 17:32:01 BST 2021
On Tue, Mar 30, 2021 at 07:42:53PM +0530, Vinod Koul wrote:
> Hi Thierry,
>
> On 25-03-21, 17:40, Thierry Reding wrote:
>
> > +static struct tegra_xusb_usb3_port *
> > +tegra210_lane_to_usb3_port(struct tegra_xusb_lane *lane)
> > +{
> > + int port;
> > +
> > + if (!lane || !lane->pad || !lane->pad->padctl)
> > + return NULL;
>
> This looks problematic to me, so if lane is NULL, it will still go ahead
> and check lane->pad which would result in NULL pointer dereference.
No, this isn't going to result in a NULL pointer dereference because the
compiler will short-circuit this if the first expression is true. If the
lane parameter is NULL, then the entire expression is going to be true
no matter what lane->pad and lane->pad->padctl evaluate to (because of
the logical OR) and hence the compiler knows that it can skip the rest.
This is a fairly common construct in kernel code.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-phy/attachments/20210331/cad6e77a/attachment.sig>
More information about the linux-phy
mailing list