]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
media: venus: vdec: Init registered list unconditionally
authorStanimir Varbanov <stanimir.varbanov@linaro.org>
Fri, 3 Apr 2020 13:10:13 +0000 (15:10 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 1 Oct 2020 11:17:58 +0000 (13:17 +0200)
[ Upstream commit bc3d870e414b42d72cd386aa20a4fc3612e4feb7 ]

Presently the list initialization is done only in
dynamic-resolution-change state, which leads to list corruptions
and use-after-free. Init list_head unconditionally in
vdec_stop_capture called by vb2 stop_streaming without takeing
into account current codec state.

Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/platform/qcom/venus/vdec.c

index 59ae7a1e63bc2131a00baf6989e30d05deb774c8..05b80a66e80edb78f91efe6c0d2b6a6b6f5de775 100644 (file)
@@ -987,13 +987,14 @@ static int vdec_stop_capture(struct venus_inst *inst)
                ret = hfi_session_flush(inst, HFI_FLUSH_OUTPUT);
                vdec_cancel_dst_buffers(inst);
                inst->codec_state = VENUS_DEC_STATE_CAPTURE_SETUP;
-               INIT_LIST_HEAD(&inst->registeredbufs);
                venus_helper_free_dpb_bufs(inst);
                break;
        default:
-               return 0;
+               break;
        }
 
+       INIT_LIST_HEAD(&inst->registeredbufs);
+
        return ret;
 }