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: 822599 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2059.outbound.protection.outlook.com [40.107.255.59]) (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 990203D552; Fri, 23 Aug 2024 08:24:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.255.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724401481; cv=fail; b=a/LnlH+3ntOjvQ/CTc+qoExV2LrWQISOS+EoZE6JltX4SsqlLQmjw5ey6qf/sZAtoAnQsezbM00EKl1Fec10q5nuucr5kb7Ihh3/QQ3IFJSwgiLMQRjawngAchw6yfX7NN357YUIHE7db3Q3ViB4J2vYUrjyc/JwuhcKyiBLtOM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724401481; c=relaxed/simple; bh=vD035+GPuFjehY+FGM9+55EMI3MK5Uwuz2cUJb27W1k=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=lC+p77Pw/jZPlG0YtoOyE2D70sJ76nsXuBmw0cOn2NKyAsA2qHz07nv4S3QzzCjb1IUCf3KAwFwR/ygy3pYvl6JHGWqQQnrtRFQqG0kPR7EklbdlBxp5TUiE/rrXpYG3G+6CInSd5fh4erSizxwDH+KsK2MKEKOSD2eyfFTlD68= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com; spf=pass smtp.mailfrom=vivo.com; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b=aX/8QRlG; arc=fail smtp.client-ip=40.107.255.59 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=vivo.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b="aX/8QRlG" 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) Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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/yznZ3DymoWvobtSxhEXlXiJ4IdTpPPmMHK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; 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 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;