From patchwork Tue Mar 8 13:16:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mirela Rabulea OSS X-Patchwork-Id: 12773798 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 79273C433F5 for ; Tue, 8 Mar 2022 13:18:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=0Ql4n1mXfE4fmIndTO0/7Ks4muUF+g1rBkWwznFe7kg=; b=P63RFOvZZ5S/Wl yPSVczBllFf+MmJd0ejvCE5fPLrJexPE6SMYMbthu37sWcVUo6RZc7RWgyH3sFMsbItu23FY/5jRq yCEvsEAoMBlgFmpIRausvyQMXaYsHtGD8I4l6/x0IWPV0Mgb7E3gJC561q786cokodq+HyUmy1Ilu SM9Z74w7fmjdFPN+3qvNvcxIei3024hCkxH8LW8T0AEty2JDhuTKGaKD/IczTn9+FYCnvvnVM33He +Uj7DRWCBR6sLq0dwvBN3mEDm8fD48d980A1fx+UKlTYv4BtBAorjZX8YEqREXDoDcgnTqFdDWjK2 ees+QsSbgtmMpseNFzZg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nRZiI-004UM8-5h; Tue, 08 Mar 2022 13:17:18 +0000 Received: from mail-am6eur05on2060e.outbound.protection.outlook.com ([2a01:111:f400:7e1b::60e] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nRZiE-004UJk-OS for linux-arm-kernel@lists.infradead.org; Tue, 08 Mar 2022 13:17:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KQqVUQZTYV5oOOsrJmI2CHIEmhlHjAHeMVqU2SmiObtOgGXOg/DbSgwixbIqZvldT/Kx2TleIoKXrIgXFKNkponxN9004r3Zvdb7Iz3Qj1Uc11L3IbPsMxyYN9wUeoMCECds0BpEXM2nVr4Mp/IlcFxBwFpFqHgfgCIsjkSA4MrzeQxfnlhqDZBGSdr9McJETFXH+LONeWlqIkVAjX5YVXo2a+M20s2E8+A/fFH0NfbufCQwIeb1Y/CeqA/oeeEJC72i57vsJgFN89b8sA8aDTa7XI16HkC+IbCzi6OuK5HYEhOUi82IIMtbVGgOx8HCNYhNJWkB1Rtx1rNnbwcjGg== 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=GpIn00TEzOeuqv1SGCj4edaQ8eXI5u/akvN31wF1dDc=; b=Y7BGY2Ty1lyiYgcJLz2tCgQsPYeoJ/N5w4bndPKEk/f9HfoZuKgOXuaEsER0WF2k6JbA4mebDAyY+LIjqkEPBYH2tZBbh1S3pvO7jekpl782/cj86yXU8Or5e0FVDFZba9sJN4MX1axqHyhNAyie0fjBYCYNjtqiGP947S+8KwagUtgssLi2Ii/RXD+znMbXpO9eFtR3MAazn/f7qGQFjK4gPHDfrQkn69irwS6jcxIk/gsIqJaQHBgMM9HFJ8mU6Iq0MoMSjTqcq/cJXq2ZdVTUmW8ZK+ZX7Is+PlEvaLwLBzheV/NplVj7uafm8ROGCLUBM9R33Js9hQ0z77LqDQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GpIn00TEzOeuqv1SGCj4edaQ8eXI5u/akvN31wF1dDc=; b=d0lsQQT5CURsnswMHAqoKkV9B+daMd9gpZME4PjDHcebF2ise3lxUV+xUk59S/mpa/T7ltVMtkDQsnUXvQWcvJuYH/j6VPNf2jC6bBlAOwiqc6PvGHfyClqFJsW5oDNyUSz2JHbK0a6MclzPinziUos8T18nZNBfXg2zL5J3km8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR0401MB2495.eurprd04.prod.outlook.com (2603:10a6:800:52::15) by AM0PR0402MB3635.eurprd04.prod.outlook.com (2603:10a6:208:a::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.16; Tue, 8 Mar 2022 13:17:08 +0000 Received: from VI1PR0401MB2495.eurprd04.prod.outlook.com ([fe80::a1ae:e74c:cadb:efb8]) by VI1PR0401MB2495.eurprd04.prod.outlook.com ([fe80::a1ae:e74c:cadb:efb8%12]) with mapi id 15.20.5038.027; Tue, 8 Mar 2022 13:17:08 +0000 From: Mirela Rabulea To: mchehab@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, dan.carpenter@oracle.com, ming.qian@nxp.com Cc: linux-media@vger.kernel.org, linux-imx@nxp.com, kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, festevam@gmail.com, robert.chiras@nxp.com Subject: [PATCH] media: imx-jpeg: Fix potential array out of bounds in queue_setup Date: Tue, 8 Mar 2022 15:16:57 +0200 Message-Id: <20220308131657.1722495-1-mirela.rabulea@oss.nxp.com> X-Mailer: git-send-email 2.25.1 X-ClientProxiedBy: VI1PR0902CA0050.eurprd09.prod.outlook.com (2603:10a6:802:1::39) To VI1PR0401MB2495.eurprd04.prod.outlook.com (2603:10a6:800:52::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b5b3173e-5cf4-4a2b-9250-08da0105f296 X-MS-TrafficTypeDiagnostic: AM0PR0402MB3635:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +FrNavQjw9oZRtAj0sPzXwxUiYFej6Hz8oYg0wKIwuYOZzIpTpxVd/9h7DKANIbGjwPota4vbTb+IjRtpi2eXoRKxfQcOLxI/KDjGO1rfT2ZhXC6o2dVA6XMORQHaSZ90Z80mXwy+Ox32R5JB9WhaeLpeHVqtoNS+c58KFA8fr7EPPj+Wbi/Ho7/IpeR/MPzimU6DFxYnPrKrbkjBSYH4Ig+B1FzbDq4OJjNBicWW5n6fHj21F1FX9uLIK+rTZmgTGX/OJikGLuvUhO4O2QrwdC9m1/YmcwKGYKMnT00rIYfWN8kKtXQhm6qT1tuTStBnfQxRPngZ8Z0iXcP0nAJOqcf6TBhgQ9xiaJ9mnP97uPslJLAk4lfxl+JeDC2C1JapGa30jHah9829e0x3PbpeKW0/abDqARNwJleT2bkY0o9LqGqvFTFz9tU7XHz/f0GiFWt1jTakOu2MnEcgHzJjJjaKgESBsHiVnioRViLq2Ln89IIF6lVav6evROkzTWM26A6W61ObKDHYTBX2aa50/up26mwxDPl/UPesvR6StG0K0UVzI9rqOyA3tTN+I/XD6OwXCdxLb4BZcIKmTRGthLXreCNfoIBcqXd8StjSFc2UtmzJb6XaSvr8JNBcc0SXZiK6lwEjZftb39305U3gtYp4A0ob0ykDedvGMTDZe5MQezjpX0z6/92Ry4AEMfjuK2jcc3YULV9/Q8hYMNnHQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR0401MB2495.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(186003)(38350700002)(26005)(1076003)(66946007)(66556008)(86362001)(8676002)(2616005)(38100700002)(4326008)(498600001)(2906002)(66476007)(6486002)(83380400001)(6506007)(8936002)(6512007)(6666004)(52116002)(44832011)(4744005)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CTk1X7xj4dser2MEhubJrrh2lXFe3wCxw9Wv12oTCTxV1l+Lc1DK1WmNbQY3LckMG/kb8Ee+Sr2Qrrr0B7Pfipxxg1SCbXuzK8mWabkWsASkxLoUE7Ff7GnMkkehkTU0Q3f1/hjrJ5UjssSXqa22mr/090gIHT0Y+Ln7qFRzKgoHICbaqd+RRYxRjpesA5fNufrhPUcPPmEFHKnQMJ6qEHFik81LSP5q4Fydxu4fgu/o1Ooy9y09nLYZdb6rt4dTFTCZFL74ODqD+aJUnUOhWMEgVlTJUe/gK6eqFcAMnruXh3Mi8mICLyaBj5pwS47rZvQy84nOU9rXLahywxlXufLitWma1nayhtoXGF72VRWBo27NuxGqHSVqgXihVpMK1qJ86j6XJ5JkLPJ/vduHTc3RcvOOJRoYaY+a7T1wOIBGwXEHdST0xE8hWvZXKMweJmcG5T5lLDHbR1wfjOCr7DC1ta6PYhEQ5Ar61PG7zsmp3ox0ku7shsPEd6baxzUpooM+b+/btyaxz7uoF0xi8l78JO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JCrZxdkl/H3srFMFnRS0PSEsvUZY= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b5b3173e-5cf4-4a2b-9250-08da0105f296 X-MS-Exchange-CrossTenant-AuthSource: VI1PR0401MB2495.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2022 13:17:08.4639 (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: jmRSGuY9lKbK0UecmC0Ph57v+KowhADbi59Jf0UcyIefnbMV8BQg2a29mp9NIV15X0Xf+uOmmKOtZg38ed8vEA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3635 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220308_051714_833717_8DEC1C9B X-CRM114-Status: UNSURE ( 9.45 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Fix smatch warning in mxc_jpeg_queue_setup, check *nplanes against current format: drivers/media/platform/imx-jpeg/mxc-jpeg.c:1070 mxc_jpeg_queue_setup() warn: potential user controlled iterator 'i' (array size 2 vs 7) Signed-off-by: Mirela Rabulea --- drivers/media/platform/imx-jpeg/mxc-jpeg.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/platform/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/imx-jpeg/mxc-jpeg.c index fed762491379..f4819168c85d 100644 --- a/drivers/media/platform/imx-jpeg/mxc-jpeg.c +++ b/drivers/media/platform/imx-jpeg/mxc-jpeg.c @@ -1066,6 +1066,8 @@ static int mxc_jpeg_queue_setup(struct vb2_queue *q, /* Handle CREATE_BUFS situation - *nplanes != 0 */ if (*nplanes) { + if (*nplanes != q_data->fmt->colplanes) + return -EINVAL; for (i = 0; i < *nplanes; i++) { if (sizes[i] < q_data->sizeimage[i]) return -EINVAL;