From patchwork Tue Aug 20 09:53:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Jiaoliang X-Patchwork-Id: 13769799 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 02A9FC3DA4A for ; Tue, 20 Aug 2024 09:53:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7F60210E649; Tue, 20 Aug 2024 09:53:19 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=vivo.com header.i=@vivo.com header.b="cp4lU8e3"; dkim-atps=neutral Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2087.outbound.protection.outlook.com [40.107.215.87]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7DC3410E649; Tue, 20 Aug 2024 09:53:17 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JXn4PGQqkAR5JyYZOJDPgLRmsxdqeIlPnUOfyoVSmqQ6YNHYX7Q/G05EzGNPou3N8e5ZkbhGwj+s6FiZRNlPOXfQ0ujjk7e8LgSs+w2IPgACw8pSxI5uxNVYhjo8iGv+BumzPq9rx3vWen4koiN70boTWmBdJG4B3EP5TfFvt5m47SiO9W3z+f5wmPUjA/5sI8HcIYctH0VbIFEH4qjg5rDp8R8SEOIR6vKopgDwUFZrc+mS594+hZX3lt3m9RBd7yvJ6Wrj1SHIbDsU6UqCP1gAH3WnQ1blqnmAK/zEfUXIgobIodPJyGiXaAueohXxs4SVRPD61/1wcd8ASTxRew== 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=J2LtEjlrjt3vnNZ92KXhjbDeqJ/eWDlPdGluGDFKb9I=; b=vaQhP8mek8L+8xTEaguMeJ3yX2+baaa5jQRmEPUDPzkSF6dIeITaZesrocjehdpSW8vY4zOkZkl+Ex+PuoPsLJewg65Alt2QxPAuSw701iBNmZtlUj4wKgV82iYt+w7M8UcSqtiE+WoZbIOwkYw47wYiLgEw0/IeMuWiYixnxBdLbekpawWSEeYXaw/+a9ap6dl0vcqBWGre5rbQztsP2w+ddpkBk+lEEcSxl0oTTlneA/vHPStRNv2tookBXL8R4DUh248xEi5gnwwGcRg9hq6mTxjH7ZKP01c4W5vydVpIqpsHKfUj3v3/gtsOk5RMzgoFWrYwhtjV99BWHfevKw== 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=J2LtEjlrjt3vnNZ92KXhjbDeqJ/eWDlPdGluGDFKb9I=; b=cp4lU8e3o8DxWBShaiEWE8rp39FikdR9c6WOIhClZsD6eW6KSaUuFFU6qh7tBnAtY1yZJaV+6obhKX+Q5Lv2Rg/r1ZticL5SgAecXDTtVwZzGDpS61vqpPA5mJwxtxLF6fJ1DROye4Ltu/yJYR2rbEWG54B4OTHFGVDY/0iufCDUgd+zwrhV36iyCB4WpHwB2ZKKO1eGzIEbV13Y3+sM6gfHFK0FHUGFgZ3RdjqmeS+7p397lyukuFBEBuRt/VThaUI76lT7y3c5Qox2zNy1PYis5q9MP18TniWiddshOmqZYu33F974Z4fr3cE7hGo7uDSEZHbiG7Fo9sVwFexjWw== 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 TY0PR06MB5529.apcprd06.prod.outlook.com (2603:1096:400:27b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Tue, 20 Aug 2024 09:53:13 +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; Tue, 20 Aug 2024 09:53:13 +0000 From: Yu Jiaoliang To: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter , Matt Roper , Andi Shyti , Michal Mrozek , Lucas De Marchi , Tejas Upadhyay , Gustavo Sousa , Shekhar Chauhan , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: opensource.kernel@vivo.com, Yu Jiaoliang , Jani Nikula Subject: [PATCH v2] drm/i915/gt: Use kmemdup_array instead of kmemdup for multiple allocation Date: Tue, 20 Aug 2024 17:53:02 +0800 Message-Id: <20240820095304.2746102-1-yujiaoliang@vivo.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: TYCP286CA0170.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:3c6::11) To TYZPR06MB4461.apcprd06.prod.outlook.com (2603:1096:400:82::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYZPR06MB4461:EE_|TY0PR06MB5529:EE_ X-MS-Office365-Filtering-Correlation-Id: c9c45e2c-a0f7-4d0d-70db-08dcc0fde818 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|1800799024|7416014|52116014|376014|38350700014|921020; X-Microsoft-Antispam-Message-Info: fNx3Dd5XWpFHeJ7fszkaa84wt+B9PiaDPHqH9xSVV8M2rUPdF9FwZsmjTfbuzgFx8jzNPnKKI5eJ+h1P9J7l3LlPM2HE9ASY1MJL18iPu/ajUiFNUhCyaRwYPLoIp2aOZgcLWNQlTfzrfApsQDvGasHkT8HTdrLKd7DFSUSzb9xcFPccIJMZpcYfjCKg2dVLoQwq7MkH4syyZ8Jh90TGleX2QrvauOIVuYNTMIGgp9+v5RjNXOajP15yyxyqkEkvilxa9cnSYg7xFuZyCDQLmyS3JCqldXcWlxIMpq32D+J1wBKlfJBqy+ovDyTVpPboYbhORHUtpdDgGV41sRJW40ozqfaO7YkSOodl1sWbuXB7hAz/nOpSH0hvDH+w7pejEYwgswRgPCMWr1bUw81ckfx/NMLbrKtQy+FozYm0qgZeUDTKKCfGj0lJ18mBIuSjtqfXzmghBG/xSBgWjAQC9GAstfF0vvlLxznD/7Tcli3UDHDJwq9iFaAv64FcHophp5GzNLO5depfPDrCxXDl7lZR6RjpPuDJQqfPvMg6lhLFk8yNzdzL3gNOSafmaphdAeGTcjYd0WUjnkFx0yZv99Qg3dU8L/JQRP1COVaH8GTtcF65bcYQ8zpl0HPdjrPeCSgebDOYvyjxIyieI2jQkWSMMctd9TyQlZMJN9sAcgl4lCGbmH332FTnVRIKVTSap7PRoJOJb5RBZQKUmmNG3z6P0KRXqm5mCBut4CK4df/so3q8Kw3+yXukdvhUajbqu/Ol0CwmpCHjzYM4zS6YT8XJrAiAUrkzxJu4nKtDQldLEsKifdvaQ0db1A+s7tMpWChfg1+jvr3ZNewde0LNwKry0JjwVeapwU/srFHbaClkMbGKzHPpjrRaLb1Jp0yPwl8MnHk1Mx3eRwQ3UrBy8ZMjjaA9rG9w0q/mrl8NvAKliz1dNNauTCXUkRWblWNLxsPawllVfe7octTKWJwyK0OWaFuFyxpVTZiNw1pg+X8OegFoO2Sq5w99lp9sRdd22fWlactaaQ3zkDeCOecxQpcw5ecj05Dko2bPGRXAqn6EBnXRMJAdqW4aPeSeC/eiawV++OTO46osDWnrRU57eDItVgyVsTJuKS38sAhBcf8RRiOItWyvxwpqmvwI0CYPgZQtVZmEn8rxTbiiqPk99FHWsqt+v4gBk8K8ajOhchWwyIcR8W0MwY0J+3KlibVE6xBmFJ9KqWGlPhz9StKkmIoa5008BEYcgOPHBR3Vhw9vHkYVu3e3dh7+GatPtBOyb3wI29kZ6KIXu8G+0qI0PM/xulJTesZqc2563+OSwemI8Q9/OhVWEVPTsE5X+wiahHzG7BfDImcDmnoMzha1agAmzLBbpa4B2+S3A0e8J9iHFB+2xLaK8gKUF+QMVU9XobCkXTDK35cDGBw4LURqtbnfW6ygDjAWtuC6sJnzCjo= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:TYZPR06MB4461.apcprd06.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(1800799024)(7416014)(52116014)(376014)(38350700014)(921020); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 510fLeETimIYYrECdUoOKa8pjibxdikum2chK6ow1mJa/eCi8Z/Ufj8s+guGIwqcBRjkxBDQ8XP9vm6GWb1hxecFijTrmcswGBhekqaLd2jzmpmW4n1rgD1XEijyamqv9h1L1UlB2mFE4mybISTCtjtJx1QwvcMmGLB+snz1GlCSHlPKFlA54eWg73BftED3xppjYoWf91pACE/o+kcp91ldS4pJlCbrxYqcUQcncEwIl5Me4zK7iGzsc17cxofNBbQwjpOt/JW6Fcge3EZzRvTh7BOhw0IbLjqszsdwtlWOIxF+vIpFBEbLgjVjNibB6b96Q5soyK7VqRMWgc3bDm+Q+q8oLqAXOtoVb5szX4G2ldL1+z4dbTDZw/zrnw+Qy+n5Ci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MSshEzeC1eTz7pgluaje1+biLB7i+efMqcU8l2YIXfKjZysufWjTyZ0oISc7H+EgrVdTN5PDLskukiyfq8GtJc1qPcPtfo9isf3g+wg3+ChKO5NeJxGJW9ag3sien3qkRVfWwen7ylpU13 X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: c9c45e2c-a0f7-4d0d-70db-08dcc0fde818 X-MS-Exchange-CrossTenant-AuthSource: TYZPR06MB4461.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2024 09:53:13.4743 (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: JJ9cxu/o0/cKZASl8Dra7nSF91zhTEJGpKlPHjXU5KZPcZDmtnQkIwMPhbo6rOnn6Fd1e1lpC27S1NMySUD0gg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY0PR06MB5529 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Let the kememdup_array() take care about multiplication and possible overflows. v2: - Change subject - Leave one blank line between the commit log and the tag section - Fix code alignment issue Signed-off-by: Yu Jiaoliang Reviewed-by: Jani Nikula Reviewed-by: Andi Shyti --- drivers/gpu/drm/i915/gt/intel_workarounds.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/gt/intel_workarounds.c b/drivers/gpu/drm/i915/gt/intel_workarounds.c index d90348c56765..0fcfd55c62b4 100644 --- a/drivers/gpu/drm/i915/gt/intel_workarounds.c +++ b/drivers/gpu/drm/i915/gt/intel_workarounds.c @@ -111,9 +111,8 @@ static void wa_init_finish(struct i915_wa_list *wal) { /* Trim unused entries. */ if (!IS_ALIGNED(wal->count, WA_LIST_CHUNK)) { - struct i915_wa *list = kmemdup_array(wal->list, - wal->count, sizeof(*list), - GFP_KERNEL); + struct i915_wa *list = kmemdup_array(wal->list, wal->count, + sizeof(*list), GFP_KERNEL); if (list) { kfree(wal->list);