From patchwork Wed Aug 21 06:49:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Jiaoliang X-Patchwork-Id: 13770864 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 244AFC52D6F for ; Wed, 21 Aug 2024 06:52:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding: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=XWBk1/O+EWyelb1Fb98/ybEcS/H+Lw04nqGvJdhA8Uk=; b=DsyBjJi4er8qKaPxDB+dwriTdw hwNTbDs4k4Iu7hE8G/FcKkq3v8W6CzK30oSVcgMitku35jLBd1FViAGOE9Rt6fxug7tcWWW1mVlST r4CI+hI18nJasXi8xjsX8rr2rcKvV0ezteZN5dPlKoNbtygr1cEZr8EKIzk6SK+y9CpuBrrjEMXmT K395t0+DzmxD7H0rIofA8YqmeZpjwYox6PfYmM90i6YYefmx3eV9jLWiSbHLCqiFY4GqRoLwGyUWA Kkwj7UAlE5mXQ1Zii7RZP4RezyM65XomzMI897iJGspm8M/zPuYkN6Sp1kMBk28oeQ787MR5gtFyG AbQxagBQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgfCi-00000007mmy-1SAk; Wed, 21 Aug 2024 06:52:24 +0000 Received: from mail-eastasiaazlp170100000.outbound.protection.outlook.com ([2a01:111:f403:c400::] helo=HK2PR02CU002.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgfC0-00000007ma3-0GW6 for linux-arm-kernel@lists.infradead.org; Wed, 21 Aug 2024 06:51:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rG009YtJVutpTu3QdyEGbHn5mxpl6HoxNz1IK5sqnWEM2t0cS5DMsh30iEeaNWRQeb+c1+d0i9juoQO5XRCzCf0NFRaJoZ1prb6fyOJMIj17AZMUIz86DyrOz6beF0Rso/1YpWTvS7QyaNHSkS6HG1JExj52j9tEktP1U6FHPu+hiIQJJrgbXhWG3cPuGBt6nGWcAXqG9H0cIgWtPD9T015nV/Q6o/Fp2GQdnKfpjpcwP+kFblaSZYn4lusZcY6CJ1ztSShU/NQ7XQ4fKTNIIDkkuZTYAftha2tXWHo+7MAe03VtSMTZqWoP5cGHYzZIm6kO/9fsjgi+XQbkPI12YA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=XWBk1/O+EWyelb1Fb98/ybEcS/H+Lw04nqGvJdhA8Uk=; b=zPWEDz+RfS1JoxG8q+rSdykKAc/lFSuUpAWuit7IPy+DdYt1ppKx/O0HPvdb7DheT9OEfPNt37yrO0WMkxNa/SwzGJ9Plklfa8WeKG5UKv0mwSqZ10rAsMuxudUaWIc4A6CS3JY5sohV3HatoUDzwzgDo8hM0X60NJTL8w3xC9ISkpSUH/E0AC6XsSGClMMFA8P73BzGnOgsvqkS23yfzE6PXQ3/3HWh9gAPKx4hP7Xc9zuhxobwCNZ+23QlBw21FPDbvU6o5xd6dvFWDQ55LyHEKwlIdg7Y/cmcqwtSPT7c1576FkWBkagAFSLJDQIKmGpYxBLmQwhanuMO2a683A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XWBk1/O+EWyelb1Fb98/ybEcS/H+Lw04nqGvJdhA8Uk=; b=TcZFnE/LasW/ewtOQ5s4Y30J/IGKVjKRMTfRyB15V8uJgXxlhLaMrQ0cafhARK31ddJ69V/B79g1A0M4Op8Z+e4nGruxn451fq9WAUJZWRcTN3c6hT+/ROlET2Hy4/bDV2NlYeD6KKTV02XzgB9wVtNQ41AmUsSDVseoV8QWiBSDG+s0KHJdc2u6j5SP7haloHAUjUx40sx2c72ziSAst2cLIKDZBaxrpjfo17zeu8vFPH7IfAwE4V5WWMms2rQtq+nL3yocdfQxpW4NK/AlS9UnzbPUQbZqINVXw1chKjEGneZHWVer88D3dEnwMRPliNWyisBIR6bY7yF2jlHjDQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from TYZPR06MB4461.apcprd06.prod.outlook.com (2603:1096:400:82::8) by TY0PR06MB4984.apcprd06.prod.outlook.com (2603:1096:400:1ac::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Wed, 21 Aug 2024 06:51:30 +0000 Received: from TYZPR06MB4461.apcprd06.prod.outlook.com ([fe80::9c62:d1f5:ede3:1b70]) by TYZPR06MB4461.apcprd06.prod.outlook.com ([fe80::9c62:d1f5:ede3:1b70%6]) with mapi id 15.20.7875.023; Wed, 21 Aug 2024 06:51:30 +0000 From: Yu Jiaoliang To: Linus Walleij , linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: opensource.kernel@vivo.com Subject: [PATCH v1] pinctrl: nomadik: Use kmemdup_array instead of kmemdup for multiple allocation Date: Wed, 21 Aug 2024 14:49:58 +0800 Message-Id: <20240821064958.4059221-1-yujiaoliang@vivo.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: TYBP286CA0008.JPNP286.PROD.OUTLOOK.COM (2603:1096:404:ce::20) To TYZPR06MB4461.apcprd06.prod.outlook.com (2603:1096:400:82::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYZPR06MB4461:EE_|TY0PR06MB4984:EE_ X-MS-Office365-Filtering-Correlation-Id: bcfc7178-2f19-4cfb-6462-08dcc1adaf91 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: 8R+KChr4A9h46T9NBGMCIJ5erpBXi3OzGm3KEmRrf98SD0m5Rvcj9haw4RzMFcY1ihlEM6EZ82SxX4obxkUuCfH0uDrfSUEMeISQcnhGvvj+g2bGM2Y4wDGieNF9F9AAo+DtSVNlrIrg8AC3vCuZVEuiNcTALwH99xSeST0H7uo3wz64OOBqDLy1/S2luFjGV4PQt2jTCAUvuZvBZNVM5w9WxwPRLhT9VQwNIGp6iK5InD3rf4SuRi8gpBeIA+gvGM8vRyXQxv/TEdSBmX9JHYqywfiOms+Ti7gEGGU4JqeAocJLvYgSu83V0wGng4ua/XPgFjR7Ha4c2vUOno7Pmbf65U0LvyyE24QdP/Zce3MbKMcmDRrhgsw4a/59P1MGL0UZGuIKRuhmJ3mBn3ODuJk63tOZN0caFn2TNrTm/AHouytSYerLchFVuqPWfapZg6Z0YPkEVm2sntePmCduHHWGw9kkmZqWz8fKvFh/hQg6E034DKXmw4eTLiZEtqqvmXDWpxSXKO5+MF28M2gd5wHNZGFCS7Is/3uaDtf5j/8zcXSnxkf33nRFIVOn0nYqDj2mPhq7tVpU/gO2uavOhprTYIIX0qpzwL6gsDY8TsqBcKITNduu5U/mqNWmXMY8Gh69VpIPaehRp4+KkMgSYXNJeUTZJ4NCOf4O5F+WfyK/btd5Mdu6ZNCuW3i3ySM021k6je5rhAjIK1tgFT5zUgABQW8wxUJbtXSd3EXEE/JFXsXZeYE2h3gROqpZkeNTYczKfYmS/iMup2hRdr38NSBML3KHnX47Rqnk1KW0DLeStLqT2RrqJ8qlETlWfI3r9SjEEnA554wF5yaPpdh3iPOhqrVcwbgUSu5yhqmbySr+i6FLDaH67XQsAQ9R7i40iJdwKUHYVVJ1qYhIcRabhl2sabXpd6fOIc6q05CfdfnwV/X4EE5WeyuTcSIiBFvOlQAoQ/sVS8oajn6urxEfwBj8RdhoEvNjXfcAy022WuagIyvDr41hPvQ2Rqy25i3xhtEeo04+VSl+qykS1SCqzXArESCeP6XXn01IR3BUa2o6q5owDO12ZxKVKMyOVpJzH+jAGkRMiDAc2KqgY1tuNVSrUM3AYcNaQP7kFB5jDe+9ohdz+QwzxJ5zq/fZcuKBdQyQQs0hX970X98cy7rg//bxdlI2fhG2KMUhDzCRcjnS9Xr6nLnfPnDuuJkGTYxkLkRzusis1f5DaDg9fwnDSpNmPgIU/8m3rlVcgsSiFDaUD6S0TaVpQRJYTXPWNk7jXF91l7k6aqXhM1cqG7bPjhY/HhWCa+S/9ss1F0j6KAi4p1YYc42/5vZ06xltf40ZE8ilzUeC8zCN+cJNO2g5LvrqG2S/psGpu+g8LnmwPLuGInERsYY5lzfjr4lICZQ8SSzVLVdS3Whcz3lBem2Y3Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TYZPR06MB4461.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(52116014)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uVi7vObn08VyZ21V3DjxbqoelSs8GS9UsivkfJJJXaFHZYIG2c3rX+3z6iFvxlqqp2n5SHsQefwaHXf/n7PVRvXL8p41VItQNAuAUxrXWgeh4PvQgT5KszVKAFhCCCnavzAJKdGiAMtZ4UzeM9QZa4MtMzOLDGVcUVXMfnnyIa2fAXrU38JPYnyYsXXb7fGjpjiRuyGSl9s2nE6ba1svQ6mIuIIaryozVKz+WDSif3i3VF1VeLrkvRoDJqBs8CYmBzdrMpdFl7WRJ0TCanxI5e2O0JkFLWuKsGnQebogIA2SSpudyzkQ9oOrcwI77lay/wCEeY4cDbsG5IZFXGxs0rTyGmDQUwlVMcW6eGoUZiuciVpg6AjPEzAmicdzcUYE/rYmlhHT8aq0NQHdzBzrJhdXpnIBO3Cp/LAU948IjJf1mRceFfYuT2ayeLJ3OledcFjl/UscpdGqpLhC9jSKH4pAATU3pmKKdt0CRz+OKcoE1qwXUM2YQvATQTQBJ/u6Y5g14D7iJ8FeGAJbhnzt2tGUEcOqJ5J1XNRapL9x717zHfvp9vybJRuAq2kkawomf7v27xRqysWDCsSEdBJYWUEfVqY X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: bcfc7178-2f19-4cfb-6462-08dcc1adaf91 X-MS-Exchange-CrossTenant-AuthSource: TYZPR06MB4461.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2024 06:51:30.0323 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2CeKcu3BSJu4Zose7q6eLKmhfPmm7ppfDF0u7e+2z5EjaoxtEu7EoymPiVdumibVChMUpt+I3FNubs29Yrw8pw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY0PR06MB4984 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240820_235140_126096_D1AA7BAE X-CRM114-Status: GOOD ( 10.68 ) 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 Let the kememdup_array() take care about multiplication and possible overflows. Signed-off-by: Yu Jiaoliang --- drivers/pinctrl/nomadik/pinctrl-abx500.c | 4 ++-- drivers/pinctrl/nomadik/pinctrl-nomadik.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/pinctrl/nomadik/pinctrl-abx500.c b/drivers/pinctrl/nomadik/pinctrl-abx500.c index 47f62c89955a..586ed303916e 100644 --- a/drivers/pinctrl/nomadik/pinctrl-abx500.c +++ b/drivers/pinctrl/nomadik/pinctrl-abx500.c @@ -716,8 +716,8 @@ static int abx500_dt_add_map_configs(struct pinctrl_map **map, if (*num_maps == *reserved_maps) return -ENOSPC; - dup_configs = kmemdup(configs, num_configs * sizeof(*dup_configs), - GFP_KERNEL); + dup_configs = kmemdup_array(configs, num_configs, sizeof(*dup_configs), + GFP_KERNEL); if (!dup_configs) return -ENOMEM; diff --git a/drivers/pinctrl/nomadik/pinctrl-nomadik.c b/drivers/pinctrl/nomadik/pinctrl-nomadik.c index fa78d5ecc685..800eba550cfd 100644 --- a/drivers/pinctrl/nomadik/pinctrl-nomadik.c +++ b/drivers/pinctrl/nomadik/pinctrl-nomadik.c @@ -601,8 +601,8 @@ static int nmk_dt_add_map_configs(struct pinctrl_map **map, if (*num_maps == *reserved_maps) return -ENOSPC; - dup_configs = kmemdup(configs, num_configs * sizeof(*dup_configs), - GFP_KERNEL); + dup_configs = kmemdup_array(configs, num_configs, sizeof(*dup_configs), + GFP_KERNEL); if (!dup_configs) return -ENOMEM;