From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 130DA11711 for ; Mon, 11 Sep 2023 14:13:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89824C433C7; Mon, 11 Sep 2023 14:13:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1694441612; bh=sA8IZQz3pJ9aMwFGwXkYekvwr9qpePhhu37wJJCSf5s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UubU0r2pGIWS2vvtgjYU1GCzXUZsB21oIFd/rOnFaPXH1UIUOFnEBxaPTvdK8rbcq oaIICQvzh/K9G0tTrMVUL10Anr+Ifwy/MUQEmlW2foBoj2pk/HFbLhY3uUL0VoMdfw Gu4qq4tJt3hQddBWqx5e3JwCbaojp9Ez33kiQwtc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Nicolas Dufresne , Ming Qian , Hans Verkuil , Sasha Levin Subject: [PATCH 6.5 475/739] media: amphion: ensure the bitops dont cross boundaries Date: Mon, 11 Sep 2023 15:44:34 +0200 Message-ID: <20230911134704.411648657@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230911134650.921299741@linuxfoundation.org> References: <20230911134650.921299741@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.5-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ming Qian [ Upstream commit 5bd28eae48589694ff4e5badb03bf75dae695b3f ] 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: 9f599f351e86 ("media: amphion: add vpu core driver") Reviewed-by: Nicolas Dufresne Signed-off-by: Ming Qian Signed-off-by: Hans Verkuil Signed-off-by: Sasha Levin --- drivers/media/platform/amphion/vpu_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/platform/amphion/vpu_core.c b/drivers/media/platform/amphion/vpu_core.c index 7863b7b53494c..2bb9f187e163c 100644 --- a/drivers/media/platform/amphion/vpu_core.c +++ b/drivers/media/platform/amphion/vpu_core.c @@ -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); -- 2.40.1