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

media: cedrus: hevc: Add check for invalid timestamp

Not all DPB entries will be used most of the time. Unused entries will
thus have invalid timestamps. They will produce negative buffer index
which is not specifically handled. This works just by chance in current
code. It will even produce bogus pointer, but since it's not used, it
won't do any harm.

Let's fix that brittle design by skipping writing DPB entry altogether
if timestamp is invalid.

Fixes: 86caab29da78 ("media: cedrus: Add HEVC/H.265 decoding support")
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>

authored by

Jernej Skrabec and committed by
Mauro Carvalho Chehab
143201a6 e39cc496

+3
+3
drivers/staging/media/sunxi/cedrus/cedrus_h265.c
··· 147 147 dpb[i].pic_order_cnt_val 148 148 }; 149 149 150 + if (buffer_index < 0) 151 + continue; 152 + 150 153 cedrus_h265_frame_info_write_single(ctx, i, dpb[i].field_pic, 151 154 pic_order_cnt, 152 155 buffer_index);