media: cedrus: hevc: Add check for invalid timestamp
authorJernej Skrabec <jernej.skrabec@gmail.com>
Mon, 18 Jul 2022 16:56:49 +0000 (18:56 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Aug 2022 12:23:34 +0000 (14:23 +0200)
commit22ae7f434f1f542f1344fc6a4dba2b8062c29e2f
tree69c949c1adbd47d6c16f9ad4942f3275189ec128
parentd7365590d15bbd9008f424ef043d1778ffe29f42
media: cedrus: hevc: Add check for invalid timestamp

[ Upstream commit 143201a6435bf65f0115435e9dc6d95c66b908e9 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/staging/media/sunxi/cedrus/cedrus_h265.c