Message ID | 20200113185934.15722-1-dafna.hirschfeld@collabora.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | media: vimc: streamer: fix memory leak in vimc subdevs if kthread_run fails | expand |
On 1/13/20 4:59 PM, Dafna Hirschfeld wrote: > 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> Thanks Helen > --- > drivers/media/platform/vimc/vimc-streamer.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/drivers/media/platform/vimc/vimc-streamer.c b/drivers/media/platform/vimc/vimc-streamer.c > index 5c5d3c068398..47a7470e581e 100644 > --- a/drivers/media/platform/vimc/vimc-streamer.c > +++ b/drivers/media/platform/vimc/vimc-streamer.c > @@ -207,8 +207,13 @@ int vimc_streamer_s_stream(struct vimc_stream *stream, > stream->kthread = kthread_run(vimc_streamer_thread, stream, > "vimc-streamer thread"); > > - if (IS_ERR(stream->kthread)) > - return PTR_ERR(stream->kthread); > + if (IS_ERR(stream->kthread)) { > + ret = PTR_ERR(stream->kthread); > + dev_err(ved->dev, "kthread_run failed with %d\n", ret); > + vimc_streamer_pipeline_terminate(stream); > + stream->kthread = NULL; > + return ret; > + } > > } else { > if (!stream->kthread) >
diff --git a/drivers/media/platform/vimc/vimc-streamer.c b/drivers/media/platform/vimc/vimc-streamer.c index 5c5d3c068398..47a7470e581e 100644 --- a/drivers/media/platform/vimc/vimc-streamer.c +++ b/drivers/media/platform/vimc/vimc-streamer.c @@ -207,8 +207,13 @@ int vimc_streamer_s_stream(struct vimc_stream *stream, stream->kthread = kthread_run(vimc_streamer_thread, stream, "vimc-streamer thread"); - if (IS_ERR(stream->kthread)) - return PTR_ERR(stream->kthread); + if (IS_ERR(stream->kthread)) { + ret = PTR_ERR(stream->kthread); + dev_err(ved->dev, "kthread_run failed with %d\n", ret); + vimc_streamer_pipeline_terminate(stream); + stream->kthread = NULL; + return ret; + } } else { if (!stream->kthread)
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> --- drivers/media/platform/vimc/vimc-streamer.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)