Message ID | 20240227021441.50434-3-baolu.lu@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-82590-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2494761dyb; Mon, 26 Feb 2024 20:59:13 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXy6TOfWcTImoMLn3vFyomaE5OZeY7WxwnPPuCTQ6r9NsRq9LOr+WIGX1xorpR4H1WcVIbSlDIXWpXqC2RkvE3AXZpW3Q== X-Google-Smtp-Source: AGHT+IFl/GaNE42O1Q90Pe7URC5JmvQTWozLndz7NVZlaWmkF9iQEAubBMKAOgVuWwGUNns6ceqo X-Received: by 2002:a5b:5c5:0:b0:dcd:1043:23c with SMTP id w5-20020a5b05c5000000b00dcd1043023cmr1180486ybp.1.1709009953774; Mon, 26 Feb 2024 20:59:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709009953; cv=pass; d=google.com; s=arc-20160816; b=nmGUigW4VQrZdHXnf0a31/cjpc4c72CcUAKiqASEMZ+tZW/IJulbDpMixtM1V03CpV Pbs3zzbyi+U4SNf1JbTX1kWuynIVyqhpk6YlmnmXxIGrpOFtCRtIaxKt9/Qj7GGsMnsy UDoAspXTwoJ3wIZAX8T4owlP/DgegJxDaOlcmlAl9NBBK76sT63/7+Uc4z2I6XkqKymK JApft2Fvx/G+rIJjek0yFX1/OgkAgQRLiSwIJGvaaV0n+0x/qqQSP6wWwyxPeolGGKoZ t6ioAsWf+4kPIlPLN2B375IAO9iqXUs+AYEretzXQUEk9GRAEsePswGpZJ2Ti/Z1cmd0 HVPg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=a6fpVLNs+PdwqdxcLeolxILoyyLi2LJgC6LkuGgkpEU=; fh=+24AZIOwsB6rN2R5rZXfKkfQNZggrrSJ6wNtGopki7U=; b=tY3bx9DyXAsx0st66YpcKsWgTyevRBJq/SgZ9Ytf6m+Z8Zf+ZA+k6y0CeqsJGWW8an 6R7XGRA7zeKeK/fDdNEvq+tXHl997AGoOqjl1NvJK5OL8F0iO4W7ra01YbXeBva5zn/5 F3KBnng3/CYJ5nKo5zhwhmrG6wjaTcGaZ9Hu8PxcCIlO+hYnGjJRxri0T7/xWmUucmjt FEW2l6gV8CpsuzmPOmAINrSUTk9icbS3gdpTLvoZl8oLSTSgSxpQnG+Lku4MKIqSTGyd J5hicY4zcaibgX3T0kEtcfb0HtiKY/SW0Uem0Xjv4HH2wJqp8r7UN/gvaw4Ztqh7nLn2 6cmg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HINFzjDG; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-82590-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82590-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d11-20020a63d64b000000b005dc491389b1si4755837pgj.679.2024.02.26.20.59.13 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 20:59:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82590-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HINFzjDG; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-82590-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82590-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 2DAD2B24D8B for <ouuuleilei@gmail.com>; Tue, 27 Feb 2024 02:21:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D645B2E3F2; Tue, 27 Feb 2024 02:20:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="HINFzjDG" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 902BEFBEA for <linux-kernel@vger.kernel.org>; Tue, 27 Feb 2024 02:20:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709000444; cv=none; b=XihzBrKzkMeH91Jcv3taH8Og26A1rra04sZyLUyg61s168Bx8IdyQgnRSd1bFMOU8C0yxky6DB1X7+a/NpIF0usSlCBE9/imxiZ1mKVK6y7jTYvqwtkHYQrYEjcln4SGjYQaB63EY8HFCt8pNXS3EYyXm7V/A12vuvwa4CTRz6Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709000444; c=relaxed/simple; bh=p9nNzOoMCIFWnVV6qNejGepeajPPfvnPiqBXwo2zx2A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RkPXocxIQBJh7nF0mmt9pJXLxaGFfbdzetI+7wM0pr62K3LP4IqTdsnu9ujfhyervELjtRGOBl5IcCB4Ozq4aLkgeYgAV1QzUvmsH2+sQZ+CG3BQPVEU3M3HbLX7Dti976qOiG7kIXz8QALdXgG15oubZRKokY1v/OMgjmNisps= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=HINFzjDG; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709000442; x=1740536442; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=p9nNzOoMCIFWnVV6qNejGepeajPPfvnPiqBXwo2zx2A=; b=HINFzjDGr2y2kPV6lLeKTDu8njXJ/kOebnMsFFx1RRpiqgxvITFgUPGv l5mK0vq3CsaojSFqE1rZR/sHobocK4pCBG9r1F4dosbhqipMTLLfOO0tk 1TUTy4N9JWRRWiSgoJaITiTf4SbqrAykeEyusqO+RPlStFUtyDnIIVU3/ navajfdrTfGYTYJRbCOM9YXH/tVK+FcR9CKO/nO4HSfcU3G1Eji0mVBYM ZqOkVT86tpcUSs32/VxLcmHcBpzr4i/fGC4cVSODmG+23ZpQBz/uTUhmp x7Fk3z18d/3yVSCBoeVdJetMN/5Fc+3mqfPAl1v/JyNhB7QZihQ4nK6UB A==; X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="6273103" X-IronPort-AV: E=Sophos;i="6.06,187,1705392000"; d="scan'208";a="6273103" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 18:20:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,187,1705392000"; d="scan'208";a="7418288" Received: from allen-box.sh.intel.com ([10.239.159.127]) by orviesa008.jf.intel.com with ESMTP; 26 Feb 2024 18:20:40 -0800 From: Lu Baolu <baolu.lu@linux.intel.com> To: Joerg Roedel <joro@8bytes.org> Cc: Tina Zhang <tina.zhang@intel.com>, Erick Archer <erick.archer@gmx.com>, Jingqi Liu <Jingqi.liu@intel.com>, iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 2/8] iommu/vt-d: Use kcalloc() instead of kzalloc() Date: Tue, 27 Feb 2024 10:14:35 +0800 Message-Id: <20240227021441.50434-3-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240227021441.50434-1-baolu.lu@linux.intel.com> References: <20240227021441.50434-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792026821019018173 X-GMAIL-MSGID: 1792026821019018173 |
Series |
[1/8] iommu/vt-d: Remove INTEL_IOMMU_BROKEN_GFX_WA
|
|
Commit Message
Baolu Lu
Feb. 27, 2024, 2:14 a.m. UTC
From: Erick Archer <erick.archer@gmx.com> This is an effort to get rid of all multiplications from allocation functions in order to prevent integer overflows [1]. Here the multiplication is obviously safe because DMAR_LATENCY_NUM is the number of latency types defined in the "latency_type" enum. enum latency_type { DMAR_LATENCY_INV_IOTLB = 0, DMAR_LATENCY_INV_DEVTLB, DMAR_LATENCY_INV_IEC, DMAR_LATENCY_PRQ, DMAR_LATENCY_NUM }; However, using kcalloc() is more appropriate [2] and improves readability. This patch has no effect on runtime behavior. Link: https://github.com/KSPP/linux/issues/162 [1] Link: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [2] Signed-off-by: Erick Archer <erick.archer@gmx.com> Reviewed-by: Kees Cook <keescook@chromium.org> Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org> Link: https://lore.kernel.org/r/20240211175143.9229-1-erick.archer@gmx.com Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> --- drivers/iommu/intel/perf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iommu/intel/perf.c b/drivers/iommu/intel/perf.c index 94ee70ac38e3..adc4de6bbd88 100644 --- a/drivers/iommu/intel/perf.c +++ b/drivers/iommu/intel/perf.c @@ -33,7 +33,7 @@ int dmar_latency_enable(struct intel_iommu *iommu, enum latency_type type) spin_lock_irqsave(&latency_lock, flags); if (!iommu->perf_statistic) { - iommu->perf_statistic = kzalloc(sizeof(*lstat) * DMAR_LATENCY_NUM, + iommu->perf_statistic = kcalloc(DMAR_LATENCY_NUM, sizeof(*lstat), GFP_ATOMIC); if (!iommu->perf_statistic) { ret = -ENOMEM;