[media] DVB, DiB9000: Fix leak in dib9000_attach()
authorJesper Juhl <jj@chaosbits.net>
Thu, 7 Apr 2011 19:34:30 +0000 (16:34 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Fri, 20 May 2011 12:28:45 +0000 (09:28 -0300)
If the second memory allocation in dib9000_attach() fails, we'll leak the
memory allocated by the first.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Cc: Patrick Boettcher <patrick.boettcher@dibcom.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/dvb/frontends/dib9000.c

index 91518761a2da96b67595cc7dcea842289e06999d..b25ef2bb5078e12260aeba7bdda2f9da45a720a1 100644 (file)
@@ -2255,8 +2255,10 @@ struct dvb_frontend *dib9000_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, c
        if (st == NULL)
                return NULL;
        fe = kzalloc(sizeof(struct dvb_frontend), GFP_KERNEL);
-       if (fe == NULL)
+       if (fe == NULL) {
+               kfree(st);
                return NULL;
+       }
 
        memcpy(&st->chip.d9.cfg, cfg, sizeof(struct dib9000_config));
        st->i2c.i2c_adap = i2c_adap;