[media] helene: fix memory leak when heleno_x_pon fails
authorColin Ian King <colin.king@canonical.com>
Sat, 13 Aug 2016 18:16:54 +0000 (15:16 -0300)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Wed, 24 Aug 2016 19:54:54 +0000 (16:54 -0300)
The error return path of failed calls to heleno_x_pon leak
memory because priv is not kfree'd.  Fix this by kfree'ing
priv before returning.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Abylay Ospan <aospan@netup.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/dvb-frontends/helene.c

index 97a8982740a6a71adcc4ad0bd629f7f89a35eb9d..3d1cd5fa49041c5e0f76406205469458b7b19672 100644 (file)
@@ -987,8 +987,10 @@ struct dvb_frontend *helene_attach_s(struct dvb_frontend *fe,
        if (fe->ops.i2c_gate_ctrl)
                fe->ops.i2c_gate_ctrl(fe, 1);
 
-       if (helene_x_pon(priv) != 0)
+       if (helene_x_pon(priv) != 0) {
+               kfree(priv);
                return NULL;
+       }
 
        if (fe->ops.i2c_gate_ctrl)
                fe->ops.i2c_gate_ctrl(fe, 0);
@@ -1021,8 +1023,10 @@ struct dvb_frontend *helene_attach(struct dvb_frontend *fe,
        if (fe->ops.i2c_gate_ctrl)
                fe->ops.i2c_gate_ctrl(fe, 1);
 
-       if (helene_x_pon(priv) != 0)
+       if (helene_x_pon(priv) != 0) {
+               kfree(priv);
                return NULL;
+       }
 
        if (fe->ops.i2c_gate_ctrl)
                fe->ops.i2c_gate_ctrl(fe, 0);