]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
media: gscpa/stv06xx: fix memory leak
authorHans Verkuil <hverkuil-cisco@xs4all.nl>
Thu, 8 Apr 2021 10:31:20 +0000 (12:31 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 19 May 2021 08:32:14 +0000 (10:32 +0200)
commit18bf31d9e6e6e0191bceab5eb30d9b777dd0cf4d
treef5d6e064330d78c59c78631ff92059fe62af9731
parent7aaee1ae1191104b30ac68ff20f61888ea20b6ae
media: gscpa/stv06xx: fix memory leak

BugLink: https://bugs.launchpad.net/bugs/1928857
[ Upstream commit 4f4e6644cd876c844cdb3bea2dd7051787d5ae25 ]

For two of the supported sensors the stv06xx driver allocates memory which
is stored in sd->sensor_priv. This memory is freed on a disconnect, but if
the probe() fails, then it isn't freed and so this leaks memory.

Add a new probe_error() op that drivers can use to free any allocated
memory in case there was a probe failure.

Thanks to Pavel Skripkin <paskripkin@gmail.com> for discovering the cause
of the memory leak.

Reported-and-tested-by: syzbot+e7f4c64a4248a0340c37@syzkaller.appspotmail.com
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/media/usb/gspca/gspca.c
drivers/media/usb/gspca/gspca.h
drivers/media/usb/gspca/stv06xx/stv06xx.c