HSI: omap_ssi: fix handling ida_simple_get result
authorAndrzej Hajda <a.hajda@samsung.com>
Mon, 21 Sep 2015 13:33:43 +0000 (15:33 +0200)
committerSebastian Reichel <sre@kernel.org>
Thu, 7 Jan 2016 15:06:22 +0000 (16:06 +0100)
The function can return negative value.

The problem has been detected using proposed semantic patch
scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2038576

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
drivers/hsi/controllers/omap_ssi.c

index f6d3100b7a328dbd65d1be63d063ad595a915bdf..27b91f14ba7a6319e12a49893c70aa47e76aebfa 100644 (file)
@@ -323,11 +323,10 @@ static int __init ssi_add_controller(struct hsi_controller *ssi,
                return -ENOMEM;
        }
 
-       ssi->id = ida_simple_get(&platform_omap_ssi_ida, 0, 0, GFP_KERNEL);
-       if (ssi->id < 0) {
-               err = ssi->id;
+       err = ida_simple_get(&platform_omap_ssi_ida, 0, 0, GFP_KERNEL);
+       if (err < 0)
                goto out_err;
-       }
+       ssi->id = err;
 
        ssi->owner = THIS_MODULE;
        ssi->device.parent = &pd->dev;