From: Frank Li <Frank.li@nxp.com>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: Qianqiang Liu <qianqiang.liu@163.com>,
hongxing.zhu@nxp.com, l.stach@pengutronix.de,
shawnguo@kernel.org, s.hauer@pengutronix.de,
linux-pci@vger.kernel.org, imx@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] PCI: imx6: Fix a "Null pointer dereference" issue
Date: Wed, 11 Sep 2024 11:21:43 -0400 [thread overview]
Message-ID: <ZuG1h664NeJ/X0ZS@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20240911141658.GA632894@bhelgaas>
On Wed, Sep 11, 2024 at 09:16:58AM -0500, Bjorn Helgaas wrote:
> On Wed, Sep 11, 2024 at 08:50:57PM +0800, Qianqiang Liu wrote:
> > The "resource_list_first_type" function may return NULL, which
> > will make "entry->offset" dereferences a NULL pointer.
> >
> > Signed-off-by: Qianqiang Liu <qianqiang.liu@163.com>
> > ---
> > drivers/pci/controller/dwc/pci-imx6.c | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
> > index 0dbc333adcff..04e90ba4e7d6 100644
> > --- a/drivers/pci/controller/dwc/pci-imx6.c
> > +++ b/drivers/pci/controller/dwc/pci-imx6.c
> > @@ -1017,13 +1017,14 @@ static u64 imx_pcie_cpu_addr_fixup(struct dw_pcie *pcie, u64 cpu_addr)
> > struct imx_pcie *imx_pcie = to_imx_pcie(pcie);
> > struct dw_pcie_rp *pp = &pcie->pp;
> > struct resource_entry *entry;
> > - unsigned int offset;
> > + unsigned int offset = 0;
> >
> > if (!(imx_pcie->drvdata->flags & IMX_PCIE_FLAG_CPU_ADDR_FIXUP))
> > return cpu_addr;
> >
> > entry = resource_list_first_type(&pp->bridge->windows, IORESOURCE_MEM);
> > - offset = entry->offset;
> > + if (entry)
> > + offset = entry->offset;
> >
> > return (cpu_addr - offset);
> > }
>
> I made the edit I proposed here:
> https://lore.kernel.org/r/20240911140721.GA630378@bhelgaas
>
> Please double-check it at:
> https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git/commit/?id=c2699778e6be
It is good.
Frank
prev parent reply other threads:[~2024-09-11 15:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-11 12:50 Qianqiang Liu
2024-09-11 14:16 ` Bjorn Helgaas
2024-09-11 15:21 ` Frank Li [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZuG1h664NeJ/X0ZS@lizhi-Precision-Tower-5810 \
--to=frank.li@nxp.com \
--cc=helgaas@kernel.org \
--cc=hongxing.zhu@nxp.com \
--cc=imx@lists.linux.dev \
--cc=l.stach@pengutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=qianqiang.liu@163.com \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®