From: Colin Ian King Date: Sat, 13 Aug 2016 18:16:54 +0000 (-0300) Subject: [media] helene: fix memory leak when heleno_x_pon fails X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=fd3223966cac9e6c3751b43c500963e9c71356f0;p=linux-beck.git [media] helene: fix memory leak when heleno_x_pon fails 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 Acked-by: Abylay Ospan Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/dvb-frontends/helene.c b/drivers/media/dvb-frontends/helene.c index 97a8982740a6..3d1cd5fa4904 100644 --- a/drivers/media/dvb-frontends/helene.c +++ b/drivers/media/dvb-frontends/helene.c @@ -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);