]> git.itanic.dy.fi Git - linux-stable/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>
Wed, 28 Sep 2022 08:56:52 +0000 (10:56 +0200)
commit1f6ab281f218c3a2b789eb976c5b1ef67139680a
tree5bd5e8c399fbe14b639b9b1b7ed4db08ee4f0cbe
parent7c308ecae736fea5e68a2a54ae8fb1e0e4f5e4d0
media: em28xx: initialize refcount before kref_get

commit c08eadca1bdfa099e20a32f8fa4b52b2f672236d upstream.

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>
[DP: drop changes related to dev->dev_next as second tuner functionality was added in 4.16]
Signed-off-by: Dragos-Marian Panait <dragos.panait@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/media/usb/em28xx/em28xx-cards.c