@@ -23,6 +23,8 @@ static void init_codecs(struct venus_core *core)
return;
for_each_set_bit(bit, &core->dec_codecs, MAX_CODEC_NUM) {
+ if (core->codecs_count >= MAX_CODEC_NUM)
+ return;
cap = &caps[core->codecs_count++];
cap->codec = BIT(bit);
cap->domain = VIDC_SESSION_TYPE_DEC;
@@ -30,6 +32,8 @@ static void init_codecs(struct venus_core *core)
}
for_each_set_bit(bit, &core->enc_codecs, MAX_CODEC_NUM) {
+ if (core->codecs_count >= MAX_CODEC_NUM)
+ return;
cap = &caps[core->codecs_count++];
cap->codec = BIT(bit);
cap->domain = VIDC_SESSION_TYPE_ENC;
There is a possibility that init_codecs is invoked multiple times during manipulated payload from video firmware. In such case, if codecs_count can get incremented to value more than MAX_CODEC_NUM, there can be OOB access. Keep a check for max accessible memory before accessing it. Cc: stable@vger.kernel.org Fixes: 1a73374a04e5 ("media: venus: hfi_parser: add common capability parser") Signed-off-by: Vikash Garodia <quic_vgarodia@quicinc.com> --- drivers/media/platform/qcom/venus/hfi_parser.c | 4 ++++ 1 file changed, 4 insertions(+)