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 use-after-free in em28xx_alloc_urbs
When kzalloc() fails, em28xx_uninit_usb_xfer() will free
usb_bufs->buf and set it to NULL. Thus the later access
to usb_bufs->buf[i] will lead to null pointer dereference.
Also the kfree(usb_bufs->buf) after that is redundant.
Fixes: d571b592c6
("media: em28xx: don't use coherent buffer for DMA transfers")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
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
dbfa04ec61
commit
a26efd1961
1 changed files with 1 additions and 5 deletions
|
@ -956,14 +956,10 @@ int em28xx_alloc_urbs(struct em28xx *dev, enum em28xx_mode mode, int xfer_bulk,
|
||||||
|
|
||||||
usb_bufs->buf[i] = kzalloc(sb_size, GFP_KERNEL);
|
usb_bufs->buf[i] = kzalloc(sb_size, GFP_KERNEL);
|
||||||
if (!usb_bufs->buf[i]) {
|
if (!usb_bufs->buf[i]) {
|
||||||
em28xx_uninit_usb_xfer(dev, mode);
|
|
||||||
|
|
||||||
for (i--; i >= 0; i--)
|
for (i--; i >= 0; i--)
|
||||||
kfree(usb_bufs->buf[i]);
|
kfree(usb_bufs->buf[i]);
|
||||||
|
|
||||||
kfree(usb_bufs->buf);
|
em28xx_uninit_usb_xfer(dev, mode);
|
||||||
usb_bufs->buf = NULL;
|
|
||||||
|
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue