From: Julia Lawall Date: Wed, 11 Jul 2012 08:58:38 +0000 (+0200) Subject: mtd: spear_smi: failure test for null rather than negative integer X-Git-Tag: next-20120904~60^2~52 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=b044c6b1ead984aaec3aea0fb4126430ffa01997;p=karo-tx-linux.git mtd: spear_smi: failure test for null rather than negative integer dev_get_platdata returns a pointer, so the failure value would be NULL rather than a negative integer. The semantic match that finds this problem is: (http://coccinelle.lip6.fr/) // @@ expression x,e; statement S1,S2; @@ *x = dev_get_platdata(...) ... when != x = e *if (x < 0) S1 else S2 // Signed-off-by: Julia Lawall Acked-by: Stefan Roese Signed-off-by: Artem Bityutskiy --- diff --git a/drivers/mtd/devices/spear_smi.c b/drivers/mtd/devices/spear_smi.c index b85f183d24c0..7c10466766c7 100644 --- a/drivers/mtd/devices/spear_smi.c +++ b/drivers/mtd/devices/spear_smi.c @@ -935,7 +935,7 @@ static int __devinit spear_smi_probe(struct platform_device *pdev) } } else { pdata = dev_get_platdata(&pdev->dev); - if (pdata < 0) { + if (!pdata) { ret = -ENODEV; dev_err(&pdev->dev, "no platform data\n"); goto err;