Commit ac568863 authored by Igor Matheus Andrade Torrente's avatar Igor Matheus Andrade Torrente Committed by Mauro Carvalho Chehab

media: em28xx: Fix possible memory leak of em28xx struct

The em28xx struct kref isn't being decreased after an error in the
em28xx_ir_init, leading to a possible memory leak.

A kref_put and em28xx_shutdown_buttons is added to the error handler code.
Signed-off-by: default avatarIgor Matheus Andrade Torrente <igormtorrente@gmail.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent a3a54bf4
...@@ -720,7 +720,8 @@ static int em28xx_ir_init(struct em28xx *dev) ...@@ -720,7 +720,8 @@ static int em28xx_ir_init(struct em28xx *dev)
dev->board.has_ir_i2c = 0; dev->board.has_ir_i2c = 0;
dev_warn(&dev->intf->dev, dev_warn(&dev->intf->dev,
"No i2c IR remote control device found.\n"); "No i2c IR remote control device found.\n");
return -ENODEV; err = -ENODEV;
goto ref_put;
} }
} }
...@@ -735,7 +736,7 @@ static int em28xx_ir_init(struct em28xx *dev) ...@@ -735,7 +736,7 @@ static int em28xx_ir_init(struct em28xx *dev)
ir = kzalloc(sizeof(*ir), GFP_KERNEL); ir = kzalloc(sizeof(*ir), GFP_KERNEL);
if (!ir) if (!ir)
return -ENOMEM; goto ref_put;
rc = rc_allocate_device(RC_DRIVER_SCANCODE); rc = rc_allocate_device(RC_DRIVER_SCANCODE);
if (!rc) if (!rc)
goto error; goto error;
...@@ -839,6 +840,9 @@ static int em28xx_ir_init(struct em28xx *dev) ...@@ -839,6 +840,9 @@ static int em28xx_ir_init(struct em28xx *dev)
dev->ir = NULL; dev->ir = NULL;
rc_free_device(rc); rc_free_device(rc);
kfree(ir); kfree(ir);
ref_put:
em28xx_shutdown_buttons(dev);
kref_put(&dev->ref, em28xx_free_device);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment