mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
media: em28xx: fix memory leak in em28xx_init_dev
In the em28xx_init_rev, if em28xx_audio_setup fails, this function fails
to deallocate the media_dev allocated in the em28xx_media_device_init.
Fix this by adding em28xx_unregister_media_device to free media_dev.
BTW, this patch is tested in my local syzkaller instance, and it can
prevent the memory leak from occurring again.
CC: Pavel Skripkin <paskripkin@gmail.com>
Fixes: 37ecc7b127
("[media] em28xx: add media controller support")
Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
Reported-by: syzkaller <syzkaller@googlegroups.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
parent
91bd11a4a5
commit
22be5a10d0
1 changed files with 12 additions and 6 deletions
|
@ -3630,8 +3630,10 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev,
|
|||
|
||||
if (dev->is_audio_only) {
|
||||
retval = em28xx_audio_setup(dev);
|
||||
if (retval)
|
||||
return -ENODEV;
|
||||
if (retval) {
|
||||
retval = -ENODEV;
|
||||
goto err_deinit_media;
|
||||
}
|
||||
em28xx_init_extension(dev);
|
||||
|
||||
return 0;
|
||||
|
@ -3650,7 +3652,7 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev,
|
|||
dev_err(&dev->intf->dev,
|
||||
"%s: em28xx_i2c_register bus 0 - error [%d]!\n",
|
||||
__func__, retval);
|
||||
return retval;
|
||||
goto err_deinit_media;
|
||||
}
|
||||
|
||||
/* register i2c bus 1 */
|
||||
|
@ -3666,9 +3668,7 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev,
|
|||
"%s: em28xx_i2c_register bus 1 - error [%d]!\n",
|
||||
__func__, retval);
|
||||
|
||||
em28xx_i2c_unregister(dev, 0);
|
||||
|
||||
return retval;
|
||||
goto err_unreg_i2c;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3676,6 +3676,12 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev,
|
|||
em28xx_card_setup(dev);
|
||||
|
||||
return 0;
|
||||
|
||||
err_unreg_i2c:
|
||||
em28xx_i2c_unregister(dev, 0);
|
||||
err_deinit_media:
|
||||
em28xx_unregister_media_device(dev);
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int em28xx_duplicate_dev(struct em28xx *dev)
|
||||
|
|
Loading…
Add table
Reference in a new issue