Skip to content

Commit cd16b8a

Browse files
Igor Matheus Andrade Torrentegregkh
authored andcommitted
media: em28xx: Fix possible memory leak of em28xx struct
[ Upstream commit ac56886 ] 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: Igor Matheus Andrade Torrente <[email protected]> Signed-off-by: Hans Verkuil <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 9b808bd commit cd16b8a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/media/usb/em28xx/em28xx-input.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,8 @@ static int em28xx_ir_init(struct em28xx *dev)
736736
dev->board.has_ir_i2c = 0;
737737
dev_warn(&dev->intf->dev,
738738
"No i2c IR remote control device found.\n");
739-
return -ENODEV;
739+
err = -ENODEV;
740+
goto ref_put;
740741
}
741742
}
742743

@@ -751,7 +752,7 @@ static int em28xx_ir_init(struct em28xx *dev)
751752

752753
ir = kzalloc(sizeof(*ir), GFP_KERNEL);
753754
if (!ir)
754-
return -ENOMEM;
755+
goto ref_put;
755756
rc = rc_allocate_device(RC_DRIVER_SCANCODE);
756757
if (!rc)
757758
goto error;
@@ -862,6 +863,9 @@ static int em28xx_ir_init(struct em28xx *dev)
862863
dev->ir = NULL;
863864
rc_free_device(rc);
864865
kfree(ir);
866+
ref_put:
867+
em28xx_shutdown_buttons(dev);
868+
kref_put(&dev->ref, em28xx_free_device);
865869
return err;
866870
}
867871

0 commit comments

Comments
 (0)