* [PATCH] PCI: imx: Fix an IS_ERR() vs NULL bug
@ 2018-12-18 8:23 Dan Carpenter
2018-12-18 8:54 ` Leonard Crestez
2018-12-18 10:57 ` Lorenzo Pieralisi
0 siblings, 2 replies; 5+ messages in thread
From: Dan Carpenter @ 2018-12-18 8:23 UTC (permalink / raw)
To: Richard Zhu, Leonard Crestez
Cc: Lorenzo Pieralisi, linux-pci, kernel-janitors, Bjorn Helgaas,
linux-arm-kernel, Lucas Stach
The device_link_add() function doesn't return error pointers, it returns
NULL if there is an error.
Fixes: 7a6991159bcd ("PCI: imx: Add multi-pd support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/pci/controller/dwc/pci-imx6.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
index b54b4590ccf9..8e7956224a5f 100644
--- a/drivers/pci/controller/dwc/pci-imx6.c
+++ b/drivers/pci/controller/dwc/pci-imx6.c
@@ -326,9 +326,9 @@ static int imx6_pcie_attach_pd(struct device *dev)
DL_FLAG_STATELESS |
DL_FLAG_PM_RUNTIME |
DL_FLAG_RPM_ACTIVE);
- if (IS_ERR(link)) {
- dev_err(dev, "Failed to add device_link to pcie pd: %ld\n", PTR_ERR(link));
- return PTR_ERR(link);
+ if (!link) {
+ dev_err(dev, "Failed to add device_link to pcie pd.\n");
+ return -EINVAL;
}
imx6_pcie->pd_pcie_phy = dev_pm_domain_attach_by_name(dev, "pcie_phy");
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] PCI: imx: Fix an IS_ERR() vs NULL bug
2018-12-18 8:23 [PATCH] PCI: imx: Fix an IS_ERR() vs NULL bug Dan Carpenter
@ 2018-12-18 8:54 ` Leonard Crestez
2018-12-18 11:02 ` Dan Carpenter
2018-12-18 10:57 ` Lorenzo Pieralisi
1 sibling, 1 reply; 5+ messages in thread
From: Leonard Crestez @ 2018-12-18 8:54 UTC (permalink / raw)
To: dan.carpenter, lorenzo.pieralisi
Cc: Richard Zhu, linux-pci, kernel-janitors, bhelgaas,
linux-arm-kernel, l.stach
On Tue, 2018-12-18 at 11:23 +0300, Dan Carpenter wrote:
> The device_link_add() function doesn't return error pointers, it returns
> NULL if there is an error.
>
> Fixes: 7a6991159bcd ("PCI: imx: Add multi-pd support")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Leonard Crestez <leonard.crestez@nxp.com>
I assume this was found with a static checker?
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] PCI: imx: Fix an IS_ERR() vs NULL bug
2018-12-18 8:23 [PATCH] PCI: imx: Fix an IS_ERR() vs NULL bug Dan Carpenter
2018-12-18 8:54 ` Leonard Crestez
@ 2018-12-18 10:57 ` Lorenzo Pieralisi
2018-12-18 11:03 ` Dan Carpenter
1 sibling, 1 reply; 5+ messages in thread
From: Lorenzo Pieralisi @ 2018-12-18 10:57 UTC (permalink / raw)
To: Dan Carpenter
Cc: Richard Zhu, linux-pci, kernel-janitors, Bjorn Helgaas,
Leonard Crestez, linux-arm-kernel, Lucas Stach
On Tue, Dec 18, 2018 at 11:23:29AM +0300, Dan Carpenter wrote:
> The device_link_add() function doesn't return error pointers, it returns
> NULL if there is an error.
>
> Fixes: 7a6991159bcd ("PCI: imx: Add multi-pd support")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/pci/controller/dwc/pci-imx6.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
Thanks Dan, if you do not mind I will squash this in the initial
commit given that it is not upstream yet.
Lorenzo
> diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
> index b54b4590ccf9..8e7956224a5f 100644
> --- a/drivers/pci/controller/dwc/pci-imx6.c
> +++ b/drivers/pci/controller/dwc/pci-imx6.c
> @@ -326,9 +326,9 @@ static int imx6_pcie_attach_pd(struct device *dev)
> DL_FLAG_STATELESS |
> DL_FLAG_PM_RUNTIME |
> DL_FLAG_RPM_ACTIVE);
> - if (IS_ERR(link)) {
> - dev_err(dev, "Failed to add device_link to pcie pd: %ld\n", PTR_ERR(link));
> - return PTR_ERR(link);
> + if (!link) {
> + dev_err(dev, "Failed to add device_link to pcie pd.\n");
> + return -EINVAL;
> }
>
> imx6_pcie->pd_pcie_phy = dev_pm_domain_attach_by_name(dev, "pcie_phy");
> --
> 2.17.1
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] PCI: imx: Fix an IS_ERR() vs NULL bug
2018-12-18 8:54 ` Leonard Crestez
@ 2018-12-18 11:02 ` Dan Carpenter
0 siblings, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2018-12-18 11:02 UTC (permalink / raw)
To: Leonard Crestez
Cc: lorenzo.pieralisi, Richard Zhu, linux-pci, kernel-janitors,
bhelgaas, linux-arm-kernel, l.stach
On Tue, Dec 18, 2018 at 08:54:36AM +0000, Leonard Crestez wrote:
> On Tue, 2018-12-18 at 11:23 +0300, Dan Carpenter wrote:
> > The device_link_add() function doesn't return error pointers, it returns
> > NULL if there is an error.
> >
> > Fixes: 7a6991159bcd ("PCI: imx: Add multi-pd support")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> Reviewed-by: Leonard Crestez <leonard.crestez@nxp.com>
>
> I assume this was found with a static checker?
It's an unpublished Smatch check... It complains about running IS_ERR()
on things which aren't an error pointer. The problem is that that
happens all the time intentionally so i haven't published it. I should
probably make a version which only complains if it is an assignment from
a function that returns NULL.
(Even then it's problematic because it can depend on the .config)
regards,
dan carpenter
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] PCI: imx: Fix an IS_ERR() vs NULL bug
2018-12-18 10:57 ` Lorenzo Pieralisi
@ 2018-12-18 11:03 ` Dan Carpenter
0 siblings, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2018-12-18 11:03 UTC (permalink / raw)
To: Lorenzo Pieralisi
Cc: Richard Zhu, linux-pci, kernel-janitors, Bjorn Helgaas,
Leonard Crestez, linux-arm-kernel, Lucas Stach
On Tue, Dec 18, 2018 at 10:57:42AM +0000, Lorenzo Pieralisi wrote:
> On Tue, Dec 18, 2018 at 11:23:29AM +0300, Dan Carpenter wrote:
> > The device_link_add() function doesn't return error pointers, it returns
> > NULL if there is an error.
> >
> > Fixes: 7a6991159bcd ("PCI: imx: Add multi-pd support")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> > drivers/pci/controller/dwc/pci-imx6.c | 6 +++---
> > 1 file changed, 3 insertions(+), 3 deletions(-)
>
> Thanks Dan, if you do not mind I will squash this in the initial
> commit given that it is not upstream yet.
>
I don't mind at all. Thanks.
regards,
dan carpenter
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-12-18 11:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-18 8:23 [PATCH] PCI: imx: Fix an IS_ERR() vs NULL bug Dan Carpenter
2018-12-18 8:54 ` Leonard Crestez
2018-12-18 11:02 ` Dan Carpenter
2018-12-18 10:57 ` Lorenzo Pieralisi
2018-12-18 11:03 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).