diff mbox

drm/i2c: tda998x: fix memory leak in case of i2c error

Message ID 20140213083316.38D7D822BD@smtp6-g21.free.fr (mailing list archive)
State New, archived
Headers show

Commit Message

Jean-Francois Moine Feb. 13, 2014, 8:13 a.m. UTC
When the creation of the second i2c client was failing, the private
buffer was not freed.

This bug was introduced by the commit 6ae668cc19e8
'drm/i2c: tda998x: check the CEC device creation'

Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
---
 drivers/gpu/drm/i2c/tda998x_drv.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Russell King - ARM Linux Feb. 13, 2014, 7:40 p.m. UTC | #1
On Thu, Feb 13, 2014 at 09:13:34AM +0100, Jean-Francois Moine wrote:
> When the creation of the second i2c client was failing, the private
> buffer was not freed.
> 
> This bug was introduced by the commit 6ae668cc19e8
> 'drm/i2c: tda998x: check the CEC device creation'
> 
> Signed-off-by: Jean-Francois Moine <moinejf@free.fr>

Since David got there first with his patch, which is identical to yours,
I'll take his description, and take this as an acked-by for it.
diff mbox

Patch

diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c
index fa18cf3..faa77f5 100644
--- a/drivers/gpu/drm/i2c/tda998x_drv.c
+++ b/drivers/gpu/drm/i2c/tda998x_drv.c
@@ -1151,8 +1151,10 @@  tda998x_encoder_init(struct i2c_client *client,
 
 	priv->current_page = 0xff;
 	priv->cec = i2c_new_dummy(client->adapter, 0x34);
-	if (!priv->cec)
+	if (!priv->cec) {
+		kfree(priv);
 		return -ENODEV;
+	}
 	priv->dpms = DRM_MODE_DPMS_OFF;
 
 	encoder_slave->slave_priv = priv;