From patchwork Mon Aug 26 04:52:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shen Lichuan X-Patchwork-Id: 822873 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2059.outbound.protection.outlook.com [40.107.117.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 2FB8310F7; Mon, 26 Aug 2024 04:53:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.117.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724648000; cv=fail; b=b4CqW4PieKagC1PyL76VCqzfzMwYCD3ABy209yXI0F8+xwiT8ktmIXvhGLPLacKHiIeHiEjV5L9FSy7SlVuS78OYzrEiMKS1lCO341SkZkbpolI3g5cxc5dTQtv6R0h6om5Fd6OMlo+LL0pJ63O2GyClh6PVGNLFI3XIx2KGojU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724648000; c=relaxed/simple; bh=G+mg6KMIu5hrK+4pODIYqEpLsV9e+wytTGgkjfXky14=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=mWvPjWrj0PF+Ra8wLLhXolSR8upo5hMwBItkAZbADYwQjzKnDnkHYaGj1xO6ZTSfQ/PV+B6LIWijcS+mqmjAgukBPT9SHTYSG93Hxfol0hu5JKc27EPRmvTku0z8mRyQzrf2TicTc3NGEFFg6AQjI7VJ1gNFcWk3Q8KEPBP0Rxo= 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=YuP2xPpu; arc=fail smtp.client-ip=40.107.117.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="YuP2xPpu" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DXaDP3laJpZcgnI/SJ7g8UDkmI1I5K1UJWS7Z2i9gfj7h/O7HkeqN4PUTVp6CZlMpXIlGX5De6rH/2lujGQuygc7JkQCPusNWXDEWrVdpVGXwhCoscJUzatLbaSSgDObrLegtVov+fbO95ec8B/G6n131hwShW4WcjmDzFPdFI6MDxSKM8sDBU/qoPiXPZkH+cT0WeUTRxm2zqlLGSUt8rQJDGUwVW1YHEE9rMD5UkVkHU3VeFtIUJ97+8AjMQ4L5RnmuaDx0kGmcgRhB9mFc7nPoDEDGsC0pXR44CWfKK7nQI6SjXSgM0POD9kBCJfVtnlrwYoq8BSyOQzf9pqAOA== 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=ogyw2i8X2lFwz6teQLTB8szg9UUm/rff9PfJSsPAoQY=; b=oHiguvOEQ1XXbsnSCdk9bHGRTq0AaM3B1cIglyN8PkWCsO9/MFdQTZpfaXrIZyPxl23/J2AAvYL07cRlUokNi0/WbpfM8Ml5r9Fn519Z4DwLzdbFSV8QITKdg3TagOJH+yx3x1coNZuUbRO1VBR8zixlD/Qi4JE6nCvF34kGKs4NPWy8obJi9FL6cMLDGjxZkWgbnSjuXGgLWKELp9IU1Dbq0zGaRW1fnD6qtmnfHWUdZnwHyyg2A52R6Kdz4GYx/HmGYADfgtHYFo0vBwX4WTBPdSwQFy7xuAM6MxVsmVWjQQnojLASl6/crY+AOrfqz5gj6/jRo2JmQU+w/EMcBA== 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=ogyw2i8X2lFwz6teQLTB8szg9UUm/rff9PfJSsPAoQY=; b=YuP2xPpuHpJj3pMJlxO2vHm+O586E0y/fGVN1teN6Twc+vXsyrh7s9SujvA5dOuZ/4R/zDZQjTM26L4dbspI5s3qGwzCITWoBr9FRTUe4Z5U2iww0VmGyLhS2Lm2ebXJxygsMniYw9TVtmODVS6iBzqWn9x0q9SNZLU/EnZ6v/Ivi5nPSJqf/AtIdoa7I2jvkP+lwcL4TQJJ9Ld0Dfz0RZim9EnZDDA7tD77ujzliUvtwM7MkWD2XT9jVtk2NVcNVuX6+55ZGEQCkMyuvKib2PbVVfi/oLUmn6h/9XJErrDQSVFpnB2pC+foPbjFkSqoXdSfxA+K9MXtaG0XobC6XQ== 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 KL1PR06MB6709.apcprd06.prod.outlook.com (2603:1096:820:fd::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Mon, 26 Aug 2024 04:53:13 +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; Mon, 26 Aug 2024 04:53:13 +0000 From: Shen Lichuan To: mitr@volny.cz, dmitry.torokhov@gmail.com Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Shen Lichuan Subject: [PATCH v1] Input: wistron_btns - use kmemdup_array instead of kmemdup for multiple allocation Date: Mon, 26 Aug 2024 12:52:53 +0800 Message-Id: <20240826045253.3503-1-shenlichuan@vivo.com> X-Mailer: git-send-email 2.17.1 X-ClientProxiedBy: SI2PR04CA0003.apcprd04.prod.outlook.com (2603:1096:4:197::23) To SEZPR06MB5899.apcprd06.prod.outlook.com (2603:1096:101:e3::16) Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5899:EE_|KL1PR06MB6709:EE_ X-MS-Office365-Filtering-Correlation-Id: 1ac86699-4d55-498a-4fa2-08dcc58afd6f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: 9JGAqBCgbu+Q9iX1S+UgNd/5i3Rpj110ibxDP1KP4VNwH2BvPCS4FA9wQ1SEM4Q1R7uX6r4R9kSCA6unDQ/ldP1M2uCu+1vP0qcNYi8C8zMYRd8OzX44kikF562cDyez8PBA+Z3ANyClsbknMqf/kWRl2xPPz29w89P5g4JijF711KN9r4cjqsWeDxIczY474/SVg19VlGGMcZtm3tDhRA2luD4+TpWQDcmL+wXmqbX5IL0ezmdugAv2QzHH7RhT3PRRWk8Gd4zwHxsbpkmLSY+f3ntLol+vkTuy/VhZRVRAXAto5NAIebQm4+sjo2YFhrRosYX7nJld9CsWJ5zCTo5SEKXkUUTwZbN2Q33g9x8HhU/WZl5ZzRK6SuQylvD99FgHl5pZxr6u13YDvOuTx62eOqvczFT3A9wDINmdRH5b0gkariIcE2FiI7btxZV1w9q4dh9S4t0AsjKyFHH0LDcj7lUeqsFjulWo6/7FAa9oh+ksjX33jNVnNOg3TRG2XGSVY7l9xNP5rw12TapB1EU+ikNVcLYQj1HG7Ga9Ni6hlsLjR9Mwp0Qm/lILfrJq6tIxRDDPSuoLckEE0+Wlh/3gmEgF80/69WWiEyNDLOzf4zF3RPeSrGVA7fkWzM2C4CN4r/Z9lWKP46vTWlOtdrJBJJ+prcy8DhfMDXV579YRGz8Pyr7UzF+qZO7n3nSLAiT/a54BbBcq5RzEMVkLznrY+MqN1mCZ/KZELBPxQ7IGzqdcElAo7HKK79ZRI8ggR/gaFZ64O1OQ68giFS7ynUp0gAqKFlDIcPZrpl4yA8cVsE9uQzmQ3FnfNmkdX4+vEWZNWtztOjLF+VQ/3kFSgCtByCeBBaLbCjkcz7TgSPk+yIiTGHPWbgSq9Jg/Q4IUmHHp4ObMlGzFdm8OltumWs3AZc17VVUVK2IksDnpThGYDbZipnw9Tak+7cnlyZnz/+8Yys/heK1u1tMNdvrauOwH+NUADUhG2FsPno4CAzKXsoIooft2u9xPH1QpD5uEv4lcUo/uYlzg920ugoQedOK6HvRn/bPW9vZlFLVpuODAtK70qSp+Hw1N71tv5kmk4UCaE7q8LWKtecx4P+6tPou288RZp7YBLNBhLgSR84A9WN3LiqQcWlR7pObtT8Qwzn8CPDESEo38URCZgW5qL4O6Hz1zXOkZphjGlZLgH79LZ6ND4BCz4YBO5R1c5fPCliFtcsonQFJf5or6v2D70uMx90TA4oNs78qx8bdrTEgJvtScloTQm0XCwLnaQTCUUtFLfb5SdZ7ncxNJYFJaPjWcXrMZQ1dUz8OsKhwSPJ83ZWYqZAaJ3t9ePikJWvClFttKgslcpwMpK4jgj0SWb5/v3sPSiF6/qpf8d0TnVtFDRBV39el+h9IsGosD3E+If+jWc9/shaE0DMMZhu0DMg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SEZPR06MB5899.apcprd06.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(52116014)(376014)(1800799024)(366016)(38350700014); DIR:OUT; SF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Dua5EVttUWOcKZtJgrTXbaTIr5+Odfx41T6zhr4O5BOo54Ku5b1ZDHr0uNtnx018ozELQILdP6Fu3YVJV02d/N9dyjr95GdC30w2m3Xq+W85wCuU3RqLsfA+sOG/8YO2wbFAk/rZV75GvMNE/rHtqXIG0errTvHaN9PKdfqBCBIu5B+3dPZOCNsRCiDZewxkIPmOHzjCU2YgRKv+JPdFMRzD5qg2lnEUKAZkPplqBZ7KB43Qe5CMsxSV/yMdEB2xjqA+lnqbWlJSDddC1QhebaVW69u+I9Gx7yh9NvVFc3hHmO0XePLqQH6trYo1FF3ZW0GGfYuraFtSCRcdglmEJGttXKeqFQXe/th3rAlhhM+G1IuX5SSeR5ZwAQfheahKdhR0ka2t71KcGnAQW7c2zF2dSRLRmSxC7a8RjK4XTkiD/9WerMdne7h2YYYLkalhpxIW2TCdW3hI1Q5H28JHxrpwlRnXOzBjd8p5CRj5wPcPzA3Lak9q3AEb9C0wV6c7FK+Zfp6+frD3t28680mamab9JHTzuYZwfVRfOH0+1NI5dvTUR/vHDwfaYOQg6Gan X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1ac86699-4d55-498a-4fa2-08dcc58afd6f X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5899.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Aug 2024 04:53:12.9948 (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: 17iOU+exyeW2fgrZGZDM/IDxt3+GK9JSq2PaO8hPRfn05iwwNP+8qND9OrTZ0tJBeB13g8d4zKEjoApYJ9vItw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR06MB6709 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 --- drivers/input/misc/wistron_btns.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c index 5c4956678cd0..907b1a4e6633 100644 --- a/drivers/input/misc/wistron_btns.c +++ b/drivers/input/misc/wistron_btns.c @@ -990,8 +990,8 @@ static int __init copy_keymap(void) for (key = keymap; key->type != KE_END; key++) length++; - new_keymap = kmemdup(keymap, length * sizeof(struct key_entry), - GFP_KERNEL); + new_keymap = kmemdup_array(keymap, length, sizeof(struct key_entry), + GFP_KERNEL); if (!new_keymap) return -ENOMEM;