From patchwork Tue Aug 27 07:21:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shen Lichuan X-Patchwork-Id: 13779006 X-Patchwork-Delegate: kuba@kernel.org Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2053.outbound.protection.outlook.com [40.107.255.53]) (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 98D5433999; Tue, 27 Aug 2024 07:21:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.255.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724743318; cv=fail; b=N2rcbTI9RTMIR+6oWBJ+/TkmAHHs23370NB1C4n82pb/vxBwIAFlGw4mIVlCTqE2L7DT1Ap7lZzZxE6E100miwnpjqCX1MFei1NJ5OteZc1upnH67whPXK6ENdCbsfWPPmnrX7F7xMuXPlWwSaMcKQUnH3WeysbS8dq2WdHC9hI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724743318; c=relaxed/simple; bh=XgnCn7jXEJtyqY+JCglGYe3hwa1MbiYH0D3FYLaypkk=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=kL8gl6InHxHNtC7IMGvmqkt4xWMp7sFIqiToY0/BbefSfGs2ien8xgD4UrsXi8OMTd/Nh9sdSH72UmCfmJPJRu/RfTEjBJAxrMS8d+P26/V9BBGtIBj+ZAe3XHF5tm7N5i3F7elp1iZyCUgdi8wJA4Yx6tIeJONQHCyFlZfCXj0= 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=k5nxYxgN; arc=fail smtp.client-ip=40.107.255.53 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="k5nxYxgN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xm/0FNkh2AxywNM3Ffu9xI3893K27nyvHIZB5nGJ57DwMwMmRzHRP7kXvUCStMZl8dDoVPG7KPWLH5ja5NDLIcyCIcbBnI13//hj/8jcerIUu/8Em3RLHpsLIKayEqPh8TD7ACWFmilaSUWcN0BAtzk8RDEuA66m+sbxEY3bPVOM3Euqv7h6kpPeicLADQ99ynabBGJGfboZpvNzTkjPC6lzBhKTmirQqfQA7GT1fHP5CKtpqtARNXkWABNZC8VX/5NFQbSZJxceb4sjpWJxhMXeYnFHqexC5yXxtQ9XFDDPHlBxgq76bPTWZ0xvJYZhw24Hb0GtboKjlribe8nEbQ== 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=iibISkDTacXmi3rr9uPgJLlKcW6aaLXE944qxsHh/bs=; b=dvEezZAMxjgJmUXwT+iLmEdO6hSYXc4YgpDWtdD5KfH8I5ixVIwE51oljVJmcaoL+n6vw12Hbpcg3nOiPz/y6ifTYd3ZAof5zMRRGNyc4lmIfblAsQMNDOg6KhGeG0tc/6ldroWOIsqX1/1ZJPfZ3XNsMFfUYA3g1F/v5vTL/Sh8mlD20q0KTkcLXD/hEidu5cvnuRaHrXKLtSDn4/YELdxZ2GkK8/u9xBiG8hR+TbS+6UtMLfN5aYP+pAxqESGC6JOAmV+2yhdW2xXI6yd+rvtz8hnG7objNbL2KoODS48cRrMR/NEd0M6QVNUHeeNLzfUcUeAF/Hi8KyUBknxTRg== 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=iibISkDTacXmi3rr9uPgJLlKcW6aaLXE944qxsHh/bs=; b=k5nxYxgN0n4ZV71ybqo9Bld7WT4n7jSZO0w4zCgaN46Z0xept+ywK293EyK0hWPgrznHTuKOwZ97e0mjYThnmt+/J0ncUC31o5XQy6crET4Y47RxsZBz+PqGnxzNiogxA8WVhbwy6cV6kdcKpSGnfIYq4tkjY2u5n1bavE/0i5R3exG7ZgzigXhb77GwE0iwg9h1mlYGg9taYm7ykTL/9wSw27sVjXcFre7+9QW5xoMqCZqHHnFegA8jO33ehToUfPAfUvEYXBrCYbsYZF5go69HSqPiuPg3VTaZ0etQsst0DP/npk7qpc5mCJAK4DdRDhEi+1sdorl4IvDpmF8pXw== 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 SG2PR06MB5262.apcprd06.prod.outlook.com (2603:1096:4:1d9::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.24; Tue, 27 Aug 2024 07:21:51 +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.021; Tue, 27 Aug 2024 07:21:51 +0000 From: Shen Lichuan To: johannes@sipsolutions.net, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, opensource.kernel@vivo.com, Shen Lichuan Subject: [PATCH v2] wifi: mac80211: use kmemdup_array instead of kmemdup for multiple allocation Date: Tue, 27 Aug 2024 15:21:15 +0800 Message-Id: <20240827072115.42680-1-shenlichuan@vivo.com> X-Mailer: git-send-email 2.17.1 X-ClientProxiedBy: SI1PR02CA0027.apcprd02.prod.outlook.com (2603:1096:4:1f4::18) To SEZPR06MB5899.apcprd06.prod.outlook.com (2603:1096:101:e3::16) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5899:EE_|SG2PR06MB5262:EE_ X-MS-Office365-Filtering-Correlation-Id: a7beffdc-5b9e-4714-a4ef-08dcc668eb89 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: OS84H3+kmIP+P87D68CE4vUfq8tRomRvBSTW0gBQycLrKRjinruk8A7BtHyopwNh/NOwJstVuQxgSnxjnRDi9FIVW/boFp12pdYeBjrzsGJd1ZdGJ7P/6u7nQkwA2kYKU4mJyygnkFhZxb2eL/r38017UexiQDyAUY2x3k6WkGgHpz41Aot1+6Uo1vJ/aSqZvS+QfHtxknMtYzYQC3eY76zyL6amm23PO72Gp6sqzgSXGTXyp/rgnLhE5rOB0oCR6tqn97daNsTAxKcW1ZmR/ZK0ONxlajv83Gu4A1w+msK2E7hwr8GdB181zT/fEGVDh+NoMM7NIXt9ON4fsz0SCS12+yYxGSreZtZd+b0KdVLQWAYA9AXf1eg1uyvopXc4Ob261qUbQjb3CuUsJVB9m0ZzEPnThMerDR3dcXlVrdjcWj+qza7h26yyIJExna7jHr7+KT9fBnKC7x+w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S:(13230040)(366016)(1800799024)(376014)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: c64CnWqBolUv7Y8SGV4AVCIUVvSs/aLwRVNCBEaAONEudK7XyvZCzDAXDzhdK2B+wy34EQ0rjbjB4zUhEm/f3yWtW+nPjzoU2HV9CJDBnZI9/whhAyxqync+APKrME2f7ipJ1V0C3FMH5K7Pad/x6t35H+eDv/oaP4GfyIwm9zHEGDWZlSDUkwE+r5L5d+U5XSCc8XJfKkji/5liscfgVQk+ZYSI7JUXV5qO6j3u9VK1XnnWQJNuBVBweqsyktEHhhl/TyJGNLzxuPgLBREj6wUdY95O9INGm6yQRCed6GLdkQYS9Tiqrf3fF5hKG5meyVuaDsUkKc5/Cvt+xzrlPP3o3nZxPH1imIlJFSyJi8Es9fz4/fmzEPlW5jUFkXP18jXCH7H/VCHlhq+HDusXsiT9ICHv64AqKKXhzkjeK4IG938Lm2melgBqdIqWXVbDSicpu9uF1MwzXMRLoHaEwzCx5uCCZ/ZwVgp3/2bwtbeZRgAndIowWZWtDnj+VI3lz+O9dS5GxYxqfp4iGX00QxFXmPva5Xl9/Uv/OLyeAGzmgFtrKDypMNWHjFVjGwd+6qNGhC+jxPm5KTusBsDrfDm4zr3L1EALIpEkaAdabruyO7MYHPCYPuAzNk4B5b4QmyQwSbG7WHhp2FFOMWxRZsCfPL/AcU7roxisCMr9Y4B1rV93MyntkEk9LCYEtolCtCq447D2x24mGW3B8ZO26CpT55qd411l98B41nIZzwU2v5YqzHPHcYLB/bGPQV83PPCSKavteqtsJ/t1quExJfmccqtg3sxMrVC9ONJ380YTDtbb/5AFSdE+iWndCjzh1/sabzQqOG8jPtJtEhRoIHecl3SFVWnmttLwMs68uxsC6J8AAA/1TAn65IjSl4hynqCF5tCCSj51Bdt+G7HLN35vEn6l7H4IRakozUHfWn3EHypFSlJ8VkoYvSkp20v3tkRT4HJGeSVHcXOpdtkiAZhla7UhwLWZgM6lRlkdF3NDBlYLef+AL8azqAvAtUbWfytVwAJ1hZiVyABrDXXjJ/dNlRJi8UTfS3Q4811YlOXoU964wFwMwB11lwYUo2uomqwK/0Ymku9nrj4DwfzCVdugand+m7JkJH5OG1uK5d8bN5h66wTkpNvY8Sbx7bKaigEfGiwcITZ/pU8Y4qzcg4hNCMQEUzyezjOsmSdkT6256OJbZ/H3jvnSySwNlO8aNt2EqWPnSFgKun1pZQFEKW3kEDcuoyfP0lEsI90NlwJhZd6aKWnbVVvJwe1shHceviiQ5W+fMiHtFuVDwK7qxd/0pIuN2nsYTkWbeVIujIenL196g3lJsNs85Px+xdBWgwc0pmIHQoFWeeyb1pZdWryqhPGg608FWmN83ndnnKsKVWibr09bKdvQlqDvnuMxJcaPChmiG5cfzJmoC/iO95mmk5r03qhpudmXql9hZcYQZu8W8eZTaTbAODdkGs7qOBs+/B/Aoizxj6oc/Xbm3WVi2GfNk9rnU+y55RXvxbhMeYdVwv+NG8Sb1zt0Kyzl2IUKkwAhRbPOFqiB+AkGfvd/TOrryoKzIeAPLeCkjnaJg2fWeamzXpVHeeeWwE7I X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: a7beffdc-5b9e-4714-a4ef-08dcc668eb89 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5899.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2024 07:21:51.2618 (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: fEGB2LTNunxwme+9DeuHIc6RPNRDmON+9g+kfo7rTEh+nki3UW/Zp3gz4VeWUtBkRiNuTc2A2h+z21zuQDPrMw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR06MB5262 X-Patchwork-Delegate: kuba@kernel.org Let the kmemdup_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 Reviewed-by: Michal Swiatkowski --- v1 -> v2: moved "sizeof(u32)" to the next line to not exceed 80 lines. net/mac80211/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/mac80211/main.c b/net/mac80211/main.c index a3104b6ea6f0..89084690350f 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c @@ -1051,9 +1051,9 @@ static int ieee80211_init_cipher_suites(struct ieee80211_local *local) return 0; /* Driver provides cipher suites, but we need to exclude WEP */ - suites = kmemdup(local->hw.wiphy->cipher_suites, - sizeof(u32) * local->hw.wiphy->n_cipher_suites, - GFP_KERNEL); + suites = kmemdup_array(local->hw.wiphy->cipher_suites, + local->hw.wiphy->n_cipher_suites, + sizeof(u32), GFP_KERNEL); if (!suites) return -ENOMEM;