From patchwork Wed Aug 21 02:41:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Jiaoliang X-Patchwork-Id: 13770734 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 EF9C4C3DA4A for ; Wed, 21 Aug 2024 02:42:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5D9A210E2AE; Wed, 21 Aug 2024 02:42:17 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=vivo.com header.i=@vivo.com header.b="lgTit2z5"; dkim-atps=neutral Received: from HK2PR02CU002.outbound.protection.outlook.com (mail-eastasiaazon11010040.outbound.protection.outlook.com [52.101.128.40]) by gabe.freedesktop.org (Postfix) with ESMTPS id 456BA10E2AE; Wed, 21 Aug 2024 02:42:14 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TqrsweLZsxXpCXxR2GoT8BOsZie8sH29/INqhQFEDqdESkhMx4MhhKFkOfAURL0HhjaGZs6WSCsJPnSDRtunBX18aWRRDpk0FBsdEkOeP9HZ5qHKilkT5iK8P9uQsnClyh153EWDnaJW9upApzl3ER6CH5+rIxJbT34US5m24sBbvSeQ8fH1rWBZ3wkehWFnkJcar5e0hbdH4y9w2A+BY3eSyLpl6XBz2m3zI5XjhJfXl1rzL8Gj7ST71uWydIyuI7uvddPT9h3ee8JApEdAtXbtlfjfQEjnFTLpv+b3N9XPkD5N6BXM/HGWWSYV2UigItwCH55jPRfYiBncfoQmNg== 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=yZeJZiOJQ38dw74Hnem2BV8612cE8faqk0pm/TFYeKY=; b=i8aacaFsseyboZhTrbtk4Thl40SosVdQAAgG64L7KYNS34aEUj9tkD4e9OHmdMz+m9uZXgIJt4XOOFKwkeMxInP3dMiGMNy+Olee/p17u4AKzHAyHPQG8E42CihRFGFd43R8NwQMEZbbRR+N6SmZtRD0e+0dRhPjm1FQZOZtiG8poL3evbP+OZkzUsoycAy8mG/6BFvSiPZcgxyxiNOaTiKr1sRRKXMoQmI1kxHwFEknH5w2N3Q914ORdUxr+tmGq69xgmVCkBEf7JlRdlMwUpHaJLcB++sC9XSwlXks5uyeujr6l4SDZRnqt2neUytYNDl4VvEF96NWFa3pOYWYYg== 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=yZeJZiOJQ38dw74Hnem2BV8612cE8faqk0pm/TFYeKY=; b=lgTit2z58vv1gtS78BvS/sjFTy43qtN1Azen6e+5bB4x6v+YIJg3SMJmq/yXX7fgb9sJ1Yl5gHHRE1J0b4CS5dHaP5Ao2DC0RN9NTKPcS9mbEhSoD3T2FgzyKfJUyJ+tn+3H9Kp6gPz05j9rJOn80LDQuEApL0QjRS/fOWzkAQMOIayakkywrQGqx1FH1PZgMlOVU3imowFs/YfN37LxLhaguwoWCo7wCoX4ntagTqCakbUuNiPkrg897r0OcakObPnq1rv5VWAzgNpMViExKGAqQVveuEgEEAIlr4tu6HSVugqa9UT1BgFIPwlZcaNG9H6qir/q+ilqh5mGY84cWQ== 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 SEZPR06MB7137.apcprd06.prod.outlook.com (2603:1096:101:232::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.20; Wed, 21 Aug 2024 02:42:08 +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 02:42:08 +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 , Shekhar Chauhan , Gustavo Sousa , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: opensource.kernel@vivo.com Subject: [PATCH v3] drm/i915/gt: Use kmemdup_array instead of kmemdup for multiple allocation Date: Wed, 21 Aug 2024 10:41:27 +0800 Message-Id: <20240821024145.3775302-1-yujiaoliang@vivo.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: TYWP286CA0003.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:178::22) To TYZPR06MB4461.apcprd06.prod.outlook.com (2603:1096:400:82::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYZPR06MB4461:EE_|SEZPR06MB7137:EE_ X-MS-Office365-Filtering-Correlation-Id: 6bca7494-bda4-42ca-9dcd-08dcc18ad9c6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|52116014|7416014|376014|366016|921020|38350700014; X-Microsoft-Antispam-Message-Info: VxFUgILAz5uicaWDteKvi1RmstyBXzylLHLOkSImz3dMOukwTcbpZ05v2+mwhQHlrvgpAQK+sVeU2K603Uorz9B/tVYYGTHbUqNumcZMJtIiss/21TO42j3ahYjYGUkMGMt9iIwg89NtvirQxwrvIjpRuIUjIrz98OnetrE47zLj0BMz4Y5dUkK51GfarP4J+XrYMd5XbdPuLW8XfTWwpcp0NGp8hH0wZJD+HAwnda3QZyaO96gAQaH+PI9xzK9xnt2desrBHBtM6CIcmqpTx/Fvct4Gc6zke2Y3xhQGa9rEJKfBsiO9KC8iaYjQfPrdTZoBiFxuqyiLvrZpv6D+6h54ge736NJDFx7lqJVAQJ6mqJokZTJmLaPs6nJG7eiBi24wGcj629wNl+LWIZ1Dj+IuNfOq5qi9+gT2plTR05xLlVb2hihuS+bzSvgOefhINu+QUIeyhpmdanNzvhLgrKaWypOikjwAw1t6Ttv1qd2oXrCgZp+uzli1j9AsvodaM1amgvuow+miO+ct51nU3hi/PUKw6xjRv1GdQHLCEeCIvjVLf8CeCUkYadrO38lseCMBkYIwXICcNbxXpSNW+1bYghKvtFPTnYCVztv8KJTtE+EsamVv1bLL/PFQ3mJG2fDVvO95pZyOt8xhltpbbSBEkHKuX+/4KUnImFbFV8BnV1jPFMeYk/nn8GwLgLmmfDka1KZLk2ONKmhNSSI0DhWY4NB0dEUEwF1rYkJsc9cpBmJVDz5ZHb3gdqH75rWkhmmyu+AR8/PI9nvLpLO0sfWoEqqbPPZGThXU2qx8AxDAdTMF/6lR878loFITDz7suJlPRw5O4SGrrx8kt6AurOEJHghHU8DV3nHKCpPDM46rozKYqJ+kJkbLRv7CqhusQNi21DHwkqZ9fhjUEheQpvuSN8JhmgTwJbVlY/IeSRmTFD9qvxpgYal9UOT9tEZM15ahrsjLgF+XMalLR6rWPJ8fNh8npz8qeLX1UzGKJ7Xi5QV1OSNRICZBiL8Oi7Rn4WFCNY+abxROqKo+eFX4hxSKC1ggaz9a1OVZ3qNgI/0ux5295BIAgjL2EBAiX55T+XvBVUwbWXDdp0F8rtb3ngT1uaCrkDVHtjFNg4qQcXi85Hj1qhXHYMTiCkXuI135jKopzGosau41QrmIpZs/hl5vxluLOj/LS93r9jcsPakIzTtSRtmw68sABxB9MmTX3gsk8eH2XAudIOo15Sd4JhaQUkovS5QZ/mHmP2gpKNpVkymf30CZnraP3/mTTAOd7NgpryKoGC2nutp+n+E13C947OmiFFiRCIYkN9jBqTRsbdoA/LL2xU7I5pLBNdRbaZ4r7ipGZgycNa3vdBlZJ5oPHeT/hUyEwJdj/MZZzBg3yxpeRsXwwO1QPWFIAhTaYx9iP+fBeTHQHLiye1E7Fihuac577pXErKPzdXTZhqo= 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)(1800799024)(52116014)(7416014)(376014)(366016)(921020)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Pba9cQuyQHyTktCRqO6iNnmNr3FqdjqbXnb/hSVATDb8ZUVvkXYvn7Fm34IE6+dcT157WkpzKPlPIQ/cH9JuGTZml10FuzpBWIf8XeRbPUHuHntEgK4RDJve+MxPVsfMoivFr6WGmY7YH1hmhZEATGlVh4yOz6NUjRsH4qj9UP/Z7EFzXc1PRjLfEGIVQkuTdoUdeUgOta9OKGQ0RYgj7IxfslMUm0gaB/On1kTqDnPbyHaeBnOfTERxTl7o69A90akdq6HHk/leDxN71y/Ul/e+ZQkRxn7fb5vsdkSspoDxeHECUrCY8N8Sg5fyfR4Vm5v+V69KqM0BXXErVDURa4KRq6um9uO1taLEfG3MRQK+0szWrDRMT7MQAOKySkWWw7QtXBS6OkHDJSloyURwLkXinateimyTzAySJR+nvr0vJK01+Apm5NY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gVIF60nsf+UIlioRfuYXWd5uQpgDNBd3+ZPD85Z8G6lY0KlwPjje5nGe6J+osLs3W X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6bca7494-bda4-42ca-9dcd-08dcc18ad9c6 X-MS-Exchange-CrossTenant-AuthSource: TYZPR06MB4461.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2024 02:42:08.4745 (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: 8YYWBEGxX7WHZ2S3pi5Ho9U9ObLpamt6vOjfJPDOywquIvc6Q0pP4U2IAwE8OBe2O5tCVcEPLf3LpubcWHc8mw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEZPR06MB7137 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 v3: - Fix code alignment - Apply the patch on a clean drm-tip 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 09a287c1aedd..3ac0213c711f 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(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);