aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJulien Brunel <brunel@diku.dk>2008-09-24 12:00:36 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-10-17 17:41:02 -0400
commitce5dee50edc8b1ac8028c17040d40a78c4b33232 (patch)
tree67db148cdf739274f7950cfcba0b6be550ea9efb /drivers
parentf0d781d59cb621e1795d510039df973d0f8b23fc (diff)
USB: isp1760: Use an IS_ERR test rather than a NULL test
In case of error, the function isp1760_register returns an ERR pointer, but never returns a NULL pointer. So after a call to this function, a NULL test should be replaced by an IS_ERR test. Moreover, we have noticed that: (1) the result of isp1760_register is assigned through the function pci_set_drvdata without an error test, (2) if the call to isp1760_register fails, the current function (isp1761_pci_probe) returns 0, and if it succeeds, it returns -ENOMEM, which seems odd. Thus, we suggest to move the test before the call to pci_set_drvdata to correct (1), and to turn it into a non IS_ERR test to correct (2). The semantic match that finds this problem is as follows: (http://www.emn.fr/x-info/coccinelle/) // <smpl> @bad_null_test@ expression x,E; statement S1, S2; @@ x = isp1760_register(...) ... when != x = E * if (x == NULL) S1 else S2 // </smpl> Signed-off-by: Julien Brunel <brunel@diku.dk> Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/host/isp1760-if.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/usb/host/isp1760-if.c b/drivers/usb/host/isp1760-if.c
index 051ef7b6bdc6..ad44bd60df98 100644
--- a/drivers/usb/host/isp1760-if.c
+++ b/drivers/usb/host/isp1760-if.c
@@ -232,9 +232,10 @@ static int __devinit isp1761_pci_probe(struct pci_dev *dev,
232 hcd = isp1760_register(pci_mem_phy0, length, dev->irq, 232 hcd = isp1760_register(pci_mem_phy0, length, dev->irq,
233 IRQF_SHARED | IRQF_DISABLED, &dev->dev, dev_name(&dev->dev), 233 IRQF_SHARED | IRQF_DISABLED, &dev->dev, dev_name(&dev->dev),
234 devflags); 234 devflags);
235 pci_set_drvdata(dev, hcd); 235 if (!IS_ERR(hcd)) {
236 if (!hcd) 236 pci_set_drvdata(dev, hcd);
237 return 0; 237 return 0;
238 }
238clean: 239clean:
239 status = -ENODEV; 240 status = -ENODEV;
240 iounmap(iobase); 241 iounmap(iobase);