“b8445e0c9336b615ca28eafd3086eb5deb83f29d”上不存在“test/java/beans/XMLDecoder/spec/TestClass.java”
提交 0f1d3387 编写于 作者: D Dongliang Mu 提交者: Yongqiang Liu

media: em28xx: initialize refcount before kref_get

stable inclusion
from stable-v4.19.238
commit 0113fa98a49a8e46a19b0ad80f29c904c6feec23
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I5RX5X
CVE: CVE-2022-3239

---------------------------

[ Upstream commit c08eadca ]

The commit 47677e51("[media] em28xx: Only deallocate struct
em28xx after finishing all extensions") adds kref_get to many init
functions (e.g., em28xx_audio_init). However, kref_init is called too
late in em28xx_usb_probe, since em28xx_init_dev before will invoke
those init functions and call kref_get function. Then refcount bug
occurs in my local syzkaller instance.

Fix it by moving kref_init before em28xx_init_dev. This issue occurs
not only in dev but also dev->dev_next.

Fixes: 47677e51 ("[media] em28xx: Only deallocate struct em28xx after finishing all extensions")
Reported-by: Nsyzkaller <syzkaller@googlegroups.com>
Signed-off-by: NDongliang Mu <mudongliangabcd@gmail.com>
Signed-off-by: NHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NGuo Mengqi <guomengqi3@huawei.com>
Reviewed-by: NXiu Jianfeng <xiujianfeng@huawei.com>
Reviewed-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
上级 b2297d93
...@@ -3816,6 +3816,8 @@ static int em28xx_usb_probe(struct usb_interface *intf, ...@@ -3816,6 +3816,8 @@ static int em28xx_usb_probe(struct usb_interface *intf,
goto err_free; goto err_free;
} }
kref_init(&dev->ref);
dev->devno = nr; dev->devno = nr;
dev->model = id->driver_info; dev->model = id->driver_info;
dev->alt = -1; dev->alt = -1;
...@@ -3916,6 +3918,8 @@ static int em28xx_usb_probe(struct usb_interface *intf, ...@@ -3916,6 +3918,8 @@ static int em28xx_usb_probe(struct usb_interface *intf,
} }
if (dev->board.has_dual_ts && em28xx_duplicate_dev(dev) == 0) { if (dev->board.has_dual_ts && em28xx_duplicate_dev(dev) == 0) {
kref_init(&dev->dev_next->ref);
dev->dev_next->ts = SECONDARY_TS; dev->dev_next->ts = SECONDARY_TS;
dev->dev_next->alt = -1; dev->dev_next->alt = -1;
dev->dev_next->is_audio_only = has_vendor_audio && dev->dev_next->is_audio_only = has_vendor_audio &&
...@@ -3970,12 +3974,8 @@ static int em28xx_usb_probe(struct usb_interface *intf, ...@@ -3970,12 +3974,8 @@ static int em28xx_usb_probe(struct usb_interface *intf,
em28xx_write_reg(dev, 0x0b, 0x82); em28xx_write_reg(dev, 0x0b, 0x82);
mdelay(100); mdelay(100);
} }
kref_init(&dev->dev_next->ref);
} }
kref_init(&dev->ref);
request_modules(dev); request_modules(dev);
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册