From patchwork Tue Jul 18 09:50:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 704223 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20B55C001DE for ; Tue, 18 Jul 2023 09:52:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232355AbjGRJvc (ORCPT ); Tue, 18 Jul 2023 05:51:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232321AbjGRJvL (ORCPT ); Tue, 18 Jul 2023 05:51:11 -0400 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2056.outbound.protection.outlook.com [40.107.247.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EACB5128; Tue, 18 Jul 2023 02:51:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B7rzXGHOoSg8J55eYkXRQyKKmYMHxKz+1CI/xzd0MFkQKy/VnEg9opRlVTHGxmoOuNgWM/YrzjtO7KzrcoUZU6D6L38DFyqB8qlgt26l2E7Vipvtlc4u+8vtSIyoqR26aSB98nfsUeVFldg0riBY3OIlewiLxqrakCUYow6xlmlVDWIoYDB+wZukIDUJzGCAjf8GHoZUGshVCth7dY07nRG43ey0UXNCpCn2rUsnhRtEis3yaeMqfg7R6BWXxS/XydWLunSy9fEuKHWcUar4/TnE+Xfe95NUvoxMzIE95n/WmVPeYbW7KxDbrGwx58VueGiN3R6F4LXGTpLM7SxjvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=20G3mcqhQwbuDatCJ1tAgjhv5x52jZDh+tZLmUBxvg8=; b=D8N7TDRc6lpw+Iueycf5ymzgMlakhbWCFnGjdu85Xa/qhE/ZN2RB3xntLypMohkQes+zyBZvhDgUeXtmXd1xyS/ApRlpRlMsYflMcPeXDjKjdUkbP4a1Kzx1/1dRmQtmhf7G3WAzOqHSkMRxH+lLZBr05ARb2AxcX6eBMCityY7EPb6ZW1/nk1IyzfzxRa0UUrTw9NhQ9+hW/A2tyQvA/8Ofafmf6Mw8vUPVb6abUTv3Qg3OAPCiezrYRA2SXTtkbd5eXpLfDZAZRk2ZfPSGiSMmw3xt6yL//TMCSh4AsxtzFswTVNwRAv8yzVOp6kDasLi4MzzYzNnqK6bKbEGwUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=20G3mcqhQwbuDatCJ1tAgjhv5x52jZDh+tZLmUBxvg8=; b=SLYK/RG0N0+FwhR06ur0H9vcdhVCTj2jjQYwAS2XvngLJAn8J4trXqDmgUfcId9zsU0KUGQyl/gp6mQBAe93g2HbDxY70iygse+7huCGfoBLeljnXhSYMFot3JdC1zbhhULq5xEM4sSZYCtgmXYyX6qYUKWcjFnKCGQMN5u9GPE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) by AS4PR04MB9243.eurprd04.prod.outlook.com (2603:10a6:20b:4e2::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.33; Tue, 18 Jul 2023 09:51:05 +0000 Received: from AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::613b:e94b:4ccd:f55a]) by AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::613b:e94b:4ccd:f55a%5]) with mapi id 15.20.6588.031; Tue, 18 Jul 2023 09:51:04 +0000 From: Ming Qian To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl Cc: shawnguo@kernel.org, robh+dt@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, xiahong.bao@nxp.com, eagle.zhou@nxp.com, tao.jiang_2@nxp.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 5/5] media: amphion: ensure the bitops don't cross boundaries Date: Tue, 18 Jul 2023 17:50:13 +0800 Message-Id: X-Mailer: git-send-email 2.38.1 In-Reply-To: References: X-ClientProxiedBy: SI2PR04CA0009.apcprd04.prod.outlook.com (2603:1096:4:197::8) To AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB6341:EE_|AS4PR04MB9243:EE_ X-MS-Office365-Filtering-Correlation-Id: 015a50e9-ba4e-4059-a296-08db87748034 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QC/lYW0mRy9Fb5j13gF30Vtvq3hQiWxPy1+Qg7Z0L5U99cAEJJmvDY20wQdrlon+RvPhiuuw7UUHd2YFum5HYtjVCOcYXYMF/1XMQvvZk76r/09MA5EbUOnyivJUzx66D9Dpvlmx7gzhWXlgoxXGfYJ9aDavkkeJqBpcL5aYrCFM9n2DY6Wmhz7r+zHCO6mPjvkvbM5xk6n6KmCKPIh1au7nSNfjBYcCAaRr0i8rQgOMGTJQxr+84RYX6s+6bxr5kHCzvVFslEfP2CBzf2ZlOowqiaktWPWN5+jLrwisC1zPnO66ol2rhw+M9CjiGLdJZY/4A3+/fTkXbzTQUxpARXrOQuf6pPMMU0nntTKqYifdU0Xs7tuRZhnDYEAqfHSwlgGyWafsiCC0ZknIuh5AtkMtxOWIdwaIl/t7SW5pokp04SS/EuAQQA1KUEpFfbiiLnJLW7ADWXE6KCEXxi/TVJREw30+IVmVFlNgyDeVQD2poYmHBgvCFfmB6sGC42u9lCEQD08evUb8QaAEbRLXPQxnjW7zJ/YjOjsvdKWWwOwOEPsAmQNcp1OsQjv9GCWqRHvBxmtyyzOUvGVHXECwKc6O2LmHujNiiLohS0MLN872lLkUhPYEMzXiZ0ZaZ0bX X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB6341.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(346002)(376002)(39860400002)(366004)(136003)(396003)(451199021)(26005)(186003)(6506007)(36756003)(83380400001)(86362001)(38100700002)(38350700002)(2616005)(4326008)(66476007)(66946007)(66556008)(316002)(8936002)(8676002)(5660300002)(7416002)(41300700001)(44832011)(2906002)(6486002)(6666004)(6512007)(52116002)(478600001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HoyTVk+/VVt2nI1mu4oDvGVAqEE1IQE9ZzVLjYemyIsh6V2cknsKlGPqxmi9VPT5+ZeRf+hwhzw4KnttUX4NynRh5qELCZuvTDHiKjfryf6jc/XQVGdNmNnLCjoh1y5cuFGLOqgeBjimmjpnjPrIRNd89kPX487RA97bdVF6QG6DuefrwXLAbTiBYzVsjCYQz/rIfKYz13SjdsQjOBrglusXQeg4HZ/pRgicNE2wDv7/sTO7RO3QFyvrqyJeE4vR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NYrpredeDr2qgKgmFXKnhYZmAOI77XFJTbEayrLi+zyF/R9JXr/9nSaelKYzf1Qeh6ptsWOAGnO+o/n8kvC9sveJJpJZlrEGSqmil7QQsJU5wkDXX/1JJp7psHTPRDsEvsvsFmHcKhkhTyrXA7VM+uziiGpdOgEXlPpydCFuEYoJ6S0A8uwjwced9WKK013f/sAakGUVvkwXJL+fWJnIoLTD+LKaxzswZjMaNzeBzM/w7lhpCYuHUJBEVIrZi+tBG0oKpqAg2Fp5leSkoL7WGJCHO X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 015a50e9-ba4e-4059-a296-08db87748034 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB6341.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jul 2023 09:51:04.9083 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 16WIEUkQmofalwWZ+KlMUUXrfltmzo9z19AvRSoKkubKYxmzZnTe2LuoqnEJlFoAgq1lt/+A5tA+WJvW3YpTUA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR04MB9243 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 --- 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 43d85a54268b..6f054700d5db 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);