Hi Andrzej

> Field usrcnt is unsigned so it cannot be lesser than zero.
> 
> 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.ha...@samsung.com>
> ---

Thank you for your patch. good catch !
I noticed current error case is not good for ssi.c
Can you agree below ?

---------
diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c
index 7db05fd..e519e30 100644
--- a/sound/soc/sh/rcar/ssi.c
+++ b/sound/soc/sh/rcar/ssi.c
@@ -403,6 +403,12 @@ static int rsnd_ssi_quit(struct rsnd_mod *mod,
        struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
        struct device *dev = rsnd_priv_to_dev(priv);
 
+       if (!ssi->usrcnt) {
+               dev_err(dev, "%s[%d] usrcnt error\n",
+                       rsnd_mod_name(mod), rsnd_mod_id(mod));
+               return -EIO;
+       }
+
        if (rsnd_ssi_is_parent(mod, io))
                goto rsnd_ssi_quit_end;
 
@@ -422,10 +428,6 @@ rsnd_ssi_quit_end:
 
        ssi->usrcnt--;
 
-       if (ssi->usrcnt < 0)
-               dev_err(dev, "%s[%d] usrcnt error\n",
-                       rsnd_mod_name(mod), rsnd_mod_id(mod));
-
        return 0;
 }
 
---------


Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to