mtd: spear_smi: failure test for null rather than negative integer

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Sat Sep 29 10:59:04 EDT 2012


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=b5170978b421222ba4c3d64d1ebd4a03d64ae42e
Commit:     b5170978b421222ba4c3d64d1ebd4a03d64ae42e
Parent:     9c6f62a7ef230253a7dfc0547c431f07d8a64721
Author:     Julia Lawall <Julia.Lawall at lip6.fr>
AuthorDate: Wed Jul 11 10:58:38 2012 +0200
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Sat Sep 29 14:53:21 2012 +0100

    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/)
    
    // <smpl>
    @@
    expression x,e;
    statement S1,S2;
    @@
    
    *x = dev_get_platdata(...)
    ... when != x = e
    *if (x < 0) S1 else S2
    // </smpl>
    
    Signed-off-by: Julia Lawall <Julia.Lawall at lip6.fr>
    Acked-by: Stefan Roese <sr at denx.de>
    Signed-off-by: Artem Bityutskiy <artem.bityutskiy at linux.intel.com>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/devices/spear_smi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/devices/spear_smi.c b/drivers/mtd/devices/spear_smi.c
index b85f183..7c10466 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;



More information about the linux-mtd-cvs mailing list