Skip to content

Commit

Permalink
media: amphion: ensure the bitops don't cross boundaries
Browse files Browse the repository at this point in the history
[ Upstream commit 5bd28ea ]

the supported_instance_count determine the instance index range,
it shouldn't exceed the bits number of instance_mask,
otherwise the bitops of instance_mask may cross boundaries

Fixes: 9f599f3 ("media: amphion: add vpu core driver")
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
mingqian-0 authored and gregkh committed Sep 13, 2023
1 parent 932d84a commit b4ee61e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/media/platform/amphion/vpu_core.c
Expand Up @@ -88,6 +88,8 @@ static int vpu_core_boot_done(struct vpu_core *core)

core->supported_instance_count = min(core->supported_instance_count, count);
}
if (core->supported_instance_count >= BITS_PER_TYPE(core->instance_mask))
core->supported_instance_count = BITS_PER_TYPE(core->instance_mask);
core->fw_version = fw_version;
vpu_core_set_state(core, VPU_CORE_ACTIVE);

Expand Down

0 comments on commit b4ee61e

Please sign in to comment.