media: vicodec: upon release, call m2m release before freeing ctrl handler
authorDafna Hirschfeld <dafna3@gmail.com>
Wed, 6 Mar 2019 21:13:25 +0000 (16:13 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 1 May 2022 15:00:34 +0000 (17:00 +0200)
commit 4d10452cd1ed619d95fde81cef837069f4c754cd upstream.

'v4l2_m2m_ctx_release' calls request complete
so it should be called before 'v4l2_ctrl_handler_free'.

Signed-off-by: Dafna Hirschfeld <dafna3@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Cc: Minh Yuan <yuanmingbuaa@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/media/platform/vicodec/vicodec-core.c

index 7a33a52eaccaa99c159f23058f7c1636f01d5b9d..9d2e1ce536ec0aac66941f4c1cff07b20a98e137 100644 (file)
@@ -1297,12 +1297,12 @@ static int vicodec_release(struct file *file)
        struct video_device *vfd = video_devdata(file);
        struct vicodec_ctx *ctx = file2ctx(file);
 
-       v4l2_fh_del(&ctx->fh);
-       v4l2_fh_exit(&ctx->fh);
-       v4l2_ctrl_handler_free(&ctx->hdl);
        mutex_lock(vfd->lock);
        v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
        mutex_unlock(vfd->lock);
+       v4l2_fh_del(&ctx->fh);
+       v4l2_fh_exit(&ctx->fh);
+       v4l2_ctrl_handler_free(&ctx->hdl);
        kfree(ctx);
 
        return 0;