From patchwork Wed Aug 21 07:24:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Jiaoliang X-Patchwork-Id: 821673 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2064.outbound.protection.outlook.com [40.107.255.64]) (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 2A3DE1B81D9; Wed, 21 Aug 2024 07:24:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.255.64 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724225074; cv=fail; b=ctL2ZIitfuzOJ0F8kpECickIOUHnKVrWY7+IMlmKDqXHfajvAEkrTalDpn7eYQ0UwSpPT/r5xteWs9RB4NqyhlSsUFBS1u4wJ6WICt/DaOF8gxZ7NggrckzfhMEY6Lvdvbg9wCRYgsdER2Grnfg3nQKt1+Tgh+aKGpQoIWyXtPc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724225074; c=relaxed/simple; bh=9v+hYoYRVS4xyp28qhtKyJLoFj8+LpEJvXOJEsXj3N8=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=K9zv2GCUYbowRyFmHbRcEjhgND83APM5opr4lq3uZc1IoiBCDgMbCfxbYSSx5YrC8yxEcJV8r+ltfV+nDj3MWBfEQwz8fhUPENOuOxxqT71QcccaqLJ2FPr1lJeGwa5PKTN5odAZotdJ2hzPQ4R+W6r7Yv/IH8BOSJs2qBh1hvA= 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=JksQw358; arc=fail smtp.client-ip=40.107.255.64 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="JksQw358" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nqQlqyp2xi6f609ghVhbW64mR8qp7kez3v0MF/tVB3MENbAbon410tNOPptAptqaR/cRFeRwqZpfnfaOfXhfrpKYqvW2YQ0zL7nUYU+xH6gVdr8oVXYMcx8OZAM/lXWxVKJLC1U/AoZ9lZzRYSVbgvFnxelPXmoL47DM289599Ny7m9ORYHiQmjaA6KGTTeWVT9/EolM7WUnoesO3wCXx7cyvqaaqnVGzVBOhye+BQDGptXqyV4K4tdET5f6Twk+fxMNBWpLDMQI0w1fhGLy6kiCypch/5VxTjypy2C8tc4ACDcwVk87lZH+r52XPO6WevTlqwmH33wq3u3FjURsdA== 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=ulqjzYFlLH+7rVvl/XnVpLsrxmoiCeu38ldhvEAWznk=; b=QA6PTThyh/3efykJ+5aonPF+T/1L4d7JraXiIbNfHbQ85C45/OUME2CZSoIhi+K/XIiWTCTOuONnyvwMVvCK6hnlwmdPzfleUflMNMtMEwkFXD0Z9bajeasuRn5djQFY0PcbZuDrT2r4dXEBfVSVdIJEv9/qlgCZBMLET/Iou+oHE6O8dOv0uajyxK33m3GMxQ5rGHBCvdU33gxsct27YEwyc9KSpqNHKhxLBcQGNtbTjAKSE6Dn5XHbrKjiv7E5KvokFDY48wQZ0s41sZ3OYHK0S7wiVfsvvkhqQEiExalbN6PnxQnwbuq0CjDRP0k+BJIVVd7JAuLEbDPegwN1ZA== 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=ulqjzYFlLH+7rVvl/XnVpLsrxmoiCeu38ldhvEAWznk=; b=JksQw358SkvaIB0WW6ACQ4eKBo5PUIz2wVNPv26HYxetiL16Upk7aeVrarFNY6wp/y5ogqkE3JOkN8qCERjkuFEMMptvj12wwCKvOK3OJjkzwVtfyFOo4JJ76P3+ZN2p7wAP7ZB3nUab1QJFoMfcCGYKmcxik8Y2cLeXjRL3+Hr/+s0goqbsH0nu9NCJXQBxhq0aR0D7WExJnDegs8fsXq28jT7Q9hNjzsqiD43UBzDA0v3pi1Z80jfKdjqmworwJ6RvciQE+eNSqHKlYDTrsgC1ivmkqugHdpUaq1PS+uTrkzZuo5bqAJ9ZRdKL6I71e6H0istRgJ5j26fXQcTPmg== 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 TY0PR06MB6883.apcprd06.prod.outlook.com (2603:1096:405:15::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.18; Wed, 21 Aug 2024 07:24: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 07:24:30 +0000 From: Yu Jiaoliang To: Johannes Berg , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: opensource.kernel@vivo.com Subject: [PATCH v1] net: wireless: Use kmemdup_array instead of kmemdup for multiple allocation Date: Wed, 21 Aug 2024 15:24:10 +0800 Message-Id: <20240821072410.4065645-1-yujiaoliang@vivo.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: TYBP286CA0043.JPNP286.PROD.OUTLOOK.COM (2603:1096:404:10a::31) To TYZPR06MB4461.apcprd06.prod.outlook.com (2603:1096:400:82::8) Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYZPR06MB4461:EE_|TY0PR06MB6883:EE_ X-MS-Office365-Filtering-Correlation-Id: e0ae4906-7fd1-4b0d-7909-08dcc1b24bfd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|52116014|376014|366016|38350700014; X-Microsoft-Antispam-Message-Info: bYuprcrFM5pTWmbdQkpRpKPBWP9ezhzv2e1Q18UWQde8LTwG9/B1xm1/VQqtRVK3df3LPuuBN7oWJ2Ur+aWfRuf8meKbEnoYB2QaAyl1MxW8icZTSXKILZLQmvrnOv4q2ZyVmTawBfCyRaMbzaASpsy3AZF/XQLDAHH/6tpwG9W96a8oy7YTAmpTr/aRs6qD2NIyObdNzvIao3OjQxNnK4hUefFdcYbJXgxBF3lks8epkZ3WHUFrQUcFO5l+MuANnGzPcIu2vnsb4vElmT0FhaNj7RmJtL5ZfGhL3EryO+iohZlQykPZIJREZCJ5MRPLlwML9csyDgvPRiLFNASlqIr1RuXuDkLGh63rVYdbWI2OMBMr5uGvAfIvJjV6Ru2O6d+StOl6a7sSUlOeNidQ/gUBjE29xyyIZR3oINiSV9Ifu8b6AMd7/z2ezPPtEjpbn+54IxY+QWq29FcvR4k+suFL7RPj/OGNobnZ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800799024)(52116014)(376014)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DWaVF7QNLyTMWw3zrHWgkhVG6zlSEa+on2ZPh0ahD4VvbWLvpNHLUu8zTw5KkphzM0yMbbMb3zXhy+jmtwG8QX77oMAHD12BqN+K3FtGOw+AnTp6ofRUNQb6aHB6EJKkopC0Yl5blR+X/5MRvFrP6z0pYsoIINHH62XSoGyfrD1LvtD/ZMar0RlAiFUc1vMpCCFjgRAVOtLhNdplcA6L0mHgPjcsaqxxiEcX5NQwGvPLAcpU16cmZI0jA7dK24cCInpr0Z9lIok5D0VQi+Y36veEd8hGINuAyPVALXEcGwUXrvT0aaGwfxG+OdY0HtysKOmPiWQWguGRu3kDZCLTyjsjJ82t02jVPbt8nMPcQi/cUK0Raz/C1G2xEhmQQlxoxC2ZzwtrODD4eyvM5qxg6BUJKXaabXgGVRTmMMFNS7SpdVQw92QXfjmpevbRE/LCLJeRDrQUdD2sWVNrqOA5hpsMklaTM/uKQWFMG0l4hy7GwhYG3JyCPc9Hbz9+4AAVrf+MFlqKT1NxQX6bvNEAaHuIaqlq59yBOZTW7XOax1yWuFw7H/XFrGrNe0adeh7xNvPuF+RxedQVP4Kn6jRo4yhehcFaCBa96txxIfnaNuziPUGZFoHVY67Ez3UiTPf1IQUlM50eC0tP7svOswjTUkXsYnG42X32ZcGy4Ym55Vijjob6zL4gJPWiM+zkuKmh7XMKXBhrQMpf925sd/daxXNqa+S2dBBLb5t1gYsbPQ0zJ5VD7u16UMJVYH8BCKrYL8eazmVcMcVBTjzDVabcm0BB31BRnjFcj1THXXp32BMMYR+E0eB0KHAK2QOmIsbZVEgz/5mcMh5cHG3uGN9cPb1lz5uiUPxWZ6XgLE+nAy9SEk2p8cCy6DJSAEZYi3wRJQNworWfQhOj4FIzxXmHy6ysresr7U54N1BU1xEBYZEBfd0Ol0uxljubUUMcI3g7kB1xuTZ0kLn98IYSl/1yAlNlNxAgZ7WdH3cSIWIYVwZ1UXXxjz9Sn4iFg/W3NHj5WPxKXPJXZ4h74O3730JIDbhoP1YvIx9a4RfYpFe37YpueozNnTUvsnVUR1oJLMOa3DOKyJ/iQEksyuXovtTmu5WSpTGTlzAA81eG7GTv2N4SwmJzAKJBt0iXWD9pdKzvNqj4H8fWXiheA9TP24Ryxx5eUA58JZAg4FUaQ/d/bA+UCOgaHZUdu+IE8gXWzPJ1VU7BMNrdV6ubHCkelq6OyCGgsYaOMJeNSJKg3fTQagVdAaV4WW0EThlchDayKg02Co6UU8V/jjzrBIjh0FT5L271Rxb/wCQfHkGqhY+hWlYy81hz3fVtA0R3WHBOY4Qjj8V24dbqeX+DXr30WyHgUgscSMnzrvKq/MbE6c2d45cpMDd0VikNMdQ++CTFymDjtImBDFOBqhNQY6bkMLWREINDmltFOLJ+eIcqQG6uCMn0hgc92UfTcr8mI7VnXMyYz85wgZpHgB+y5sXpzvquJXzjVw43GZ/C5ZiHH8N+KcSmP8xKKOzoO1fbdn7j66ypa63kja8TeY/nuUKu4hjeHSGJiwID16YokfprVSo1HEI6rtz1gcRCjcTG2rlhTADs X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: e0ae4906-7fd1-4b0d-7909-08dcc1b24bfd X-MS-Exchange-CrossTenant-AuthSource: TYZPR06MB4461.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2024 07:24:30.4921 (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: emiBDJubAaaCCLwWs5UNm2bqIbpFd0zJfElGCXOWcs7/Mlz0z7/p2oEwWsuHu81QMKwVqfUHsb6eyiVKJYW/zA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY0PR06MB6883 Let the kememdup_array() take care about multiplication and possible overflows. Signed-off-by: Yu Jiaoliang --- net/wireless/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/wireless/util.c b/net/wireless/util.c index 9a7c3adc8a3b..6cf19dda5d2a 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c @@ -2435,8 +2435,8 @@ int cfg80211_iter_combinations(struct wiphy *wiphy, if (params->num_different_channels > c->num_different_channels) continue; - limits = kmemdup(c->limits, sizeof(limits[0]) * c->n_limits, - GFP_KERNEL); + limits = kmemdup_array(c->limits, c->n_limits, sizeof(limits[0]), + GFP_KERNEL); if (!limits) return -ENOMEM;