PCI: imx: Fix an IS_ERR() vs NULL bug
Subsystems (5)
PATCH 1/1 PCI: imx: Fix an IS_ERR() vs NULL bug
The device_link_add() function doesn't return error pointers, it returns NULL if there is an error.
--- drivers/pci/controller/dwc/pci-imx6.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pci/controller/dwc/pci-imx6.c +3 -3
@@ -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" );
Signature · 1 line
2.17.1
T24gVHVlLCAyMDE4LTEyLTE4IGF0IDExOjIzICswMzAwLCBEYW4gQ2FycGVudGVyIHdyb3RlOg0K PiBUaGUgZGV2aWNlX2xpbmtfYWRkKCkgZnVuY3Rpb24gZG9lc24ndCByZXR1cm4gZXJyb3IgcG9p bnRlcnMsIGl0IHJldHVybnMNCj4gTlVMTCBpZiB0aGVyZSBpcyBhbiBlcnJvci4NCj4gDQo+IEZp eGVzOiA3YTY5OTExNTliY2QgKCJQQ0k6IGlteDogQWRkIG11bHRpLXBkIHN1cHBvcnQiKQ0KPiBT aWduZWQtb2ZmLWJ5OiBEYW4gQ2FycGVudGVyIDxkYW4uY2FycGVudGVyQG9yYWNsZS5jb20+DQoN ClJldmlld2VkLWJ5OiBMZW9uYXJkIENyZXN0ZXogPGxlb25hcmQuY3Jlc3RlekBueHAuY29tPg0K DQpJIGFzc3VtZSB0aGlzIHdhcyBmb3VuZCB3aXRoIGEgc3RhdGljIGNoZWNrZXI/DQo
Quoted 10 lines · Leonard Crestez
Quoted 5 lines · Dan Carpenter
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 <[email protected]>Reviewed-by Leonard Crestez <[email protected]>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
Quoted 8 lines · Dan Carpenter
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 <[email protected]>--- 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
Quoted 20 lines
drivers/pci/controller/dwc/pci-imx6.c +3
-3@@ -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" );Signature · 1 line
2.17.1
Quoted 4 lines · Lorenzo Pieralisi
Quoted 3 lines · Dan Carpenter
The
device_link_add()function doesn't return error pointers, it returns NULL if there is an error.
Quoted 9 lines
Quoted 5 lines
Fixes 7a6991159bcd ("PCI: imx: Add multi-pd support")Signed-off-by Dan Carpenter <[email protected]>--- 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