Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: vimc: streamer: fix memory leak in vimc subdevs if kthread_run fails

In case kthread_run fails, the vimc subdevices
should be notified that streaming stopped so they can
release the memory for the streaming. Also, kthread should be
set to NULL.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Acked-by: Helen Koike <helen.koike@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

authored by

Dafna Hirschfeld and committed by
Mauro Carvalho Chehab
ceeb2e61 23c72dd9

+7 -2
+7 -2
drivers/media/platform/vimc/vimc-streamer.c
··· 207 207 stream->kthread = kthread_run(vimc_streamer_thread, stream, 208 208 "vimc-streamer thread"); 209 209 210 - if (IS_ERR(stream->kthread)) 211 - return PTR_ERR(stream->kthread); 210 + if (IS_ERR(stream->kthread)) { 211 + ret = PTR_ERR(stream->kthread); 212 + dev_err(ved->dev, "kthread_run failed with %d\n", ret); 213 + vimc_streamer_pipeline_terminate(stream); 214 + stream->kthread = NULL; 215 + return ret; 216 + } 212 217 213 218 } else { 214 219 if (!stream->kthread)