From patchwork Fri Aug 23 08:24:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shen Lichuan X-Patchwork-Id: 13774767 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 CB6CEC531DC for ; Fri, 23 Aug 2024 08:41: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: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=GmPM02ph6BW5C7tmT6hXy2+cA48fSak8DeXOX65CSGY=; b=48jYSexvM17HgkPZQEwYrfFhgx Iq0DmdmqiwZLTzeNjmVghA/ZLY8WAJ1P1PffAKbeii+yawS0nHd5GBGTYr05QN/DpBCmq/OokM1p/ M3bWejXrAIrCfxKrtYL3dshzrwoPWxZy+TcWpyLx+mQk2WiEBlr0zwmo/geFef7y6k09EttUCezHS tnf0rloSHQU+XEPHaLPIdWVO0wo7pwudwqJUbEpfRIL8XS4KT0RWOXH7tJUPXdYkQyPenBqezRGph +bf5E0/7m0PP08uSWwHSuPVgl0Wn4LFXZ/Lc3qeuypGDnKDwY6q5Bv1cUEAZ985QElJVZ3lf/MIR+ l2KsYvew==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shPrE-0000000FvUy-0mz8; Fri, 23 Aug 2024 08:41:20 +0000 Received: from mail-sgaapc01on20618.outbound.protection.outlook.com ([2a01:111:f400:feab::618] helo=APC01-SG2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shPbA-0000000Fqzo-43Lt for linux-arm-kernel@lists.infradead.org; Fri, 23 Aug 2024 08:24:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=t2ocU7mVPZP8WTPHzt1zaf3GYeYxtD8dN6+v0k1b0/WZpqwhP9FWysNYYPQBpQOOUtHqI1RSqSOSxKdAty7Ax2ucKrsV1Dw1P+Rho3/b4eBRVHX8tHxxXFZhblEU2PuJ4u6/UsPMYdSxwRPvjJvKO1YwNnCWEdBfy3niHRg62kwulaOR7SBZaICMO90sYoAiZ7CtJWqiWFKK6QvnPTT3Z/ubiOxrk0LNY680Oc40W6jDs23D6y4oTZD79dbuE52GHesGly/P53j7L9fcUn+OMhpO18I+NvcZf1Dv41doJZN36w9yr5Pk14eXU140ch+E4ZsA+g05+Zo6XNWXIWS3bg== 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=GmPM02ph6BW5C7tmT6hXy2+cA48fSak8DeXOX65CSGY=; b=iXVUgLi9UcrC8QOiGcDjyLhxpRcMzap//VjeVMx5TDR42Jgu5ELD0kAsH00BSlhUlKtoyZTaOa74uDhSd2qaotkWVJ2qOYJSfZmW0az6XFZ6tUo/tFJtEUJJleNQmXhwyEk8RDhupaTMxx/F3lRe5TxpdYURjg4cA/Wllj6Ke+C7HmH3oaoQxGZrMC/XBCxo3gxq9BVemVP4r9wYcsDwoV4lcpGDg/F/WbqDohSu89ks0pJsPkfbnkIxGHZ7NJD+uM5IFQTWjYAwk+wpuElBPCabYNoBDVH+UgR/thCNkAr5Uow/J0xWAwtK7wIdd3SfTUViymJ0xICXqJI5BgeNUA== 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=GmPM02ph6BW5C7tmT6hXy2+cA48fSak8DeXOX65CSGY=; b=aX/8QRlG5Q1IskiK3OvoOxNtmJtjSLq7UGesrO1YHn/jSz0en2ZBg6U3YXGNzDcsXubfXMdyTjfAJS+KM1mzClmETN8bbyLAxWWCm9q84cu2/W/ieZMAs1waaRnUQHeTJJsosSBfyDJngGgLC3h6VL2MnL0X+RzUoTlYpudnKeQznRq/cCy1rnYtSyZ1fHK/A409mzmazEsI9tZdl8u+vQ9mvdp4Dpc6hHNyiVKoEPwi4BsbF4pgepkaAOFoMTMBDQRRIW04pZg020M4RDbMkZwIzzNIxuHvI0NbRNRaQ7EbKQSPmR4g0+5Hs9vRcc69DUapZWvuurYkrAovQxPucg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEZPR06MB5899.apcprd06.prod.outlook.com (2603:1096:101:e3::16) by SEYPR06MB5232.apcprd06.prod.outlook.com (2603:1096:101:85::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19; Fri, 23 Aug 2024 08:24:33 +0000 Received: from SEZPR06MB5899.apcprd06.prod.outlook.com ([fe80::8bfc:f1ee:8923:77ce]) by SEZPR06MB5899.apcprd06.prod.outlook.com ([fe80::8bfc:f1ee:8923:77ce%3]) with mapi id 15.20.7897.014; Fri, 23 Aug 2024 08:24:33 +0000 From: Shen Lichuan To: krzk@kernel.org, s.nawrocki@samsung.com, linus.walleij@linaro.org Cc: alim.akhtar@samsung.com, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, opensource.kernel@vivo.com, Shen Lichuan Subject: [PATCH v1] drivers/pinctrl/samsung: Use kmemdup_array instead of kmemdup for multiple allocation Date: Fri, 23 Aug 2024 16:24:07 +0800 Message-Id: <20240823082407.48219-1-shenlichuan@vivo.com> X-Mailer: git-send-email 2.17.1 X-ClientProxiedBy: SI2PR02CA0030.apcprd02.prod.outlook.com (2603:1096:4:195::17) To SEZPR06MB5899.apcprd06.prod.outlook.com (2603:1096:101:e3::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5899:EE_|SEYPR06MB5232:EE_ X-MS-Office365-Filtering-Correlation-Id: 4ec7f153-ce1d-4088-2275-08dcc34d0474 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: +mxq+RnnM+E6dQUw+eNopg0XusEF5WVHd0Fz+LG9HsVP/PUhKSjUGCBLR6ISsfPxh69a7IDh+NScDp0djjLJ5o+CgDj/CdFgTlGAe7JYFHkoaL4XLPERbSnEJid9uZ7sx6A0iWPhycidhwAyADQQgyghJtUqbqBILmv7EW6rZVd/buTS7wXoWWP3eBSdN6fCeY0fWl+aHUx4fV0nyyjzVoA8anIHIfpQur/SA86T9qJqYK03mbLhUYHylU1WITa631fy7yxXaRSvnoQbGYnHLY9XnRxoteDjQKrXQnSGibo6OSEqyLu9IsTglBTySm4nEfaUvW58kDUZ/MUwU6BXSeeLF4dItpFUEIJLk6ZkYEeTD3usrAnxcg3mwemzkpn883wAnG1PCE02f44kxVSeUBTlghR85981sxk/yznZ3DymoWvobtSxhEXlXiJ4IdT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od.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(366016)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EKgHSJuq86CaWhGpLvb23mtFWEIuDEpl1J69iXLHOZGbR22hBKgeXxoqJdyzKQd4Yg6vGUZjB++NvTK3tguY+q7WflhxiMWX+kld09fi8cQHFofwkTQBiS2dfWXOIuqJrV8O6jRW9iXhIkS/iUt4to/t/Mtnunk6y8dIeoxvcVPdq8Gam8/DzGfAnbPqESGG8ZMN5s1Prh2KEuOEv7izYBnTbELEar5aYpWcftF5U5Tty6+7weM824IW+dDCYqO+8p0cqaHPBjTUFIdk7fKHFCfgdMdgsGHYllGNl9HTtsojaIKrxXUcHM/K1SgiyVP8zZCp0OkjA25r1XY67kkEKRn9mFniZOG2Ji6uquL8KKf/7sRmUPD+GgHqa6Ue/X3qriFZk4b/zMRh2tY/4TzK8l4QwTTWzSxOAXCxXjS5wOvdlurt99FmKyfPZxg7KWBfHZs8jjTiQL15FVjSRyMHXOIR1B/huNBaKJYJo8oCZudzFscFfPaK9sz9eYwSFUsz9+YZcclXkZNmrc3HNe5edapefKKykJ3kfgXXh3D0fx6m5Fcd40DJd4NO1lWdud/FRbnsF7oB3xKgTfo4StcLL2RiJqON3kCG0FGROCUkKZruveAilwda5tifddrR+1IpbIPRa9KUnvaxvLpLmJwsCb+hkOVNI/oeBoJlIqHTnCpT3Ol6am3fZ7++SP15R+ovij5rcdC5QX+CgmBYnZITDVgZwbTPE9W7JEF1YpbZwIv2v2wa6mI9Rb9MaLluXy3HDqesCBwxtYV0unNcU2YfDdQULqQZKcZ5eAdILvDwEFD9BckmxTXKKQquY4TuJUYsUWh/+rwyyM/Dq73I919IYiPKKKfeI9q2jAPBbXt+4RnJ/2+oyu6YAGXcaJ/VMUVyysFuQoMCs/zF5t2Mt0Xf78yyhsvgtVt8RkSS1xj4rNmxdaXzSI9cduIQwEEpzBHYSFYdgASdTpXLDAIAxdvzSMuAceJ7QV8kkr/4u2WiQJDUDU3vSfwF98pToHq0Ml3AzyvmwAfJBG8EG/gAhdL1HloEb1vCfKydt/VTh1Xoh5wzuaMxUbkWzmdibcm0/VMkW1cZk973TYkjlLYlV5QVvDDJ/nRS+4fAuoPwBDjSUX/GSCSm2sEXYH+mQyWR+m+QWOrwHV3FDHVq6LljzO06YUwbNPaRvg5Isar/gpb4dO7+CFaMlnEbx/4NNyq5c1XZlo5i1a2tQCHXe9qOKCTkNHM5ZH48cJRjtTxyNVFmunr1DVT6/cevefBEY/76x56/p3pUQvYlZjDNbbfQj2m3ZPL9yjKLG540Vn5lkpOUZ09ZPz5iMiUqWXP7uuMfIW5VkK8rzOqGGmeGDM3gK2jkCAi5zEOiOq4OX7JHdsC0yWpO6wg8+OlCzoOQy0xwdBlJ1VV0u/IerVCDiWwGa6uiuewc1u9U6TYn9gnXp48kJZ6wIfuZ1cS4zQ5zO4uLuDI0aOXpX9Qm4558BGrdyWTCgGkptslWGPrR7JvHfblTtQtdUI9nOHHVuZHb1I9AmiBGd4kBg/4laGv+7O2Vh9x1/Ax+Ia+dnJoRTRoOAEABmpEV2FEBs1ulbknhp/pCnRnl X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4ec7f153-ce1d-4088-2275-08dcc34d0474 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5899.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2024 08:24:33.6655 (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: JKKPh+51VfsDRKYrICG29opdBk7k4ZKT2Zp7e4UsAlcC2ON8gcNXZwOPSCD+umM4WFNx+jtcEC1bPg7yfwV0rQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR06MB5232 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240823_012445_074880_9E531937 X-CRM114-Status: GOOD ( 10.17 ) 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. Using kmemdup_array() is more appropriate and makes the code easier to audit. Signed-off-by: Shen Lichuan --- drivers/pinctrl/samsung/pinctrl-samsung.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.c b/drivers/pinctrl/samsung/pinctrl-samsung.c index e4464ee815f9..da24890f27f7 100644 --- a/drivers/pinctrl/samsung/pinctrl-samsung.c +++ b/drivers/pinctrl/samsung/pinctrl-samsung.c @@ -122,8 +122,8 @@ static int add_map_configs(struct device *dev, struct pinctrl_map **map, if (WARN_ON(*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;