]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
ISDN HiSax: uninitialized return in hisax_cs_setup
authorFlorin Malita <fmalita@gmail.com>
Wed, 18 Jul 2007 22:04:46 +0000 (18:04 -0400)
committerJeff Garzik <jeff@garzik.org>
Wed, 18 Jul 2007 22:17:23 +0000 (18:17 -0400)
Coverity (1792) spotted a possibly uninitialized return value in case of
kmalloc() failure:

1116 static int hisax_cs_setup(int cardnr, struct IsdnCard *card,
1117                           struct IsdnCardState *cs)
1119         int ret;
1120
1121         if (!(cs->rcvbuf = kmalloc(MAX_DFRAME_LEN_L1, GFP_ATOMIC))) {
1122                 printk(KERN_WARNING "HiSax: No memory for isac rcvbuf\n");
1123                 ll_unload(cs);
1124                 goto outf_cs;
...
1165 outf_cs:
1166         kfree(cs);
1167         card->cs = NULL;
1168         return ret;

The straightforward solution would be to just add the missing
initialization but hardcoding the return value in the out_cs branch
(only taken on failure) seems to work just as well and it allows killing
a couple of other lines too.

Signed-off-by: Florin Malita <fmalita@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
drivers/isdn/hisax/config.c

index 5f7907e57090cc93c259d81629ee9e602577cf67..97097ef3491e6622e4188136d224d3b38297c612 100644 (file)
@@ -1146,14 +1146,12 @@ static int hisax_cs_setup(int cardnr, struct IsdnCard *card,
        }
        if (ret) {
                closecard(cardnr);
-               ret = 0;
                goto outf_cs;
        }
        init_tei(cs, cs->protocol);
        ret = CallcNewChan(cs);
        if (ret) {
                closecard(cardnr);
-               ret = 0;
                goto outf_cs;
        }
        /* ISAR needs firmware download first */
@@ -1165,7 +1163,7 @@ static int hisax_cs_setup(int cardnr, struct IsdnCard *card,
 outf_cs:
        kfree(cs);
        card->cs = NULL;
-       return ret;
+       return 0;
 }
 
 static int checkcard(int cardnr, char *id, int *busy_flag, struct module *lockowner)