]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
media: em28xx: initialize refcount before kref_get
authorDongliang Mu <mudongliangabcd@gmail.com>
Sat, 22 Jan 2022 07:44:59 +0000 (15:44 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Apr 2022 12:05:50 +0000 (14:05 +0200)
commit37f808a9e734e9036f7aa42ba4864fc6e91d2572
treebd0b9a51b35cf89c829fd4898a1f34a6782e0dfe
parent91e2805579ab0783eed53acc2bf9fb553e939004
media: em28xx: initialize refcount before kref_get

[ Upstream commit c08eadca1bdfa099e20a32f8fa4b52b2f672236d ]

The commit 47677e51e2a4("[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: 47677e51e2a4 ("[media] em28xx: Only deallocate struct em28xx after finishing all extensions")
Reported-by: syzkaller <syzkaller@googlegroups.com>
Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/usb/em28xx/em28xx-cards.c