From patchwork Tue Oct 27 13:47:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 312784 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E792C61DD8 for ; Tue, 27 Oct 2020 14:55:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2885C22284 for ; Tue, 27 Oct 2020 14:55:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603810514; bh=lcte25DQ0I5zKue9ZIyN70bxF85x8e2iVDHlwfavOmI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=1DAouYn4QxEJ4LzYhCp5RgAbD3Kk8RBomyfpgpffUiRyGUbH4LF4fKi/b/cV9zjh7 CpmuwARF0LtB3QT3C+i/2cSyFmBKJwYYrh7o2cn0zA1tAKnIp28bKuYq/0JE4fMEUR Zo+XM82KVh9TbZuoN9HODkJlIDEPuSZfoceBN1bM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S368544AbgJ0Oy5 (ORCPT ); Tue, 27 Oct 2020 10:54:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:51318 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1773467AbgJ0Ov7 (ORCPT ); Tue, 27 Oct 2020 10:51:59 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 88D9B22258; Tue, 27 Oct 2020 14:51:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603810319; bh=lcte25DQ0I5zKue9ZIyN70bxF85x8e2iVDHlwfavOmI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WOndGmWcrh0HTKB75TRNmu2817d0BF0y6LxrfsXJVX867Ce+FMAXuiZw5qioFIpTF zj8QeYSCngDJeHbyARX1ujua6poCmKBMqrSzrILt6SCtWrslshqCJmuVpKA50qnWVs R/1IelAzuA18DwBdi8OivrylWHoZvtaP+dF2o4KY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , "Peter Zijlstra (Intel)" , Sasha Levin Subject: [PATCH 5.8 097/633] x86/events/amd/iommu: Fix sizeof mismatch Date: Tue, 27 Oct 2020 14:47:20 +0100 Message-Id: <20201027135527.251698280@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Colin Ian King [ Upstream commit 59d5396a4666195f89a67e118e9e627ddd6f53a1 ] An incorrect sizeof is being used, struct attribute ** is not correct, it should be struct attribute *. Note that since ** is the same size as * this is not causing any issues. Improve this fix by using sizeof(*attrs) as this allows us to not even reference the type of the pointer. Addresses-Coverity: ("Sizeof not portable (SIZEOF_MISMATCH)") Fixes: 51686546304f ("x86/events/amd/iommu: Fix sysfs perf attribute groups") Signed-off-by: Colin Ian King Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20201001113900.58889-1-colin.king@canonical.com Signed-off-by: Sasha Levin --- arch/x86/events/amd/iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/events/amd/iommu.c b/arch/x86/events/amd/iommu.c index fb616203ce427..be50ef8572cce 100644 --- a/arch/x86/events/amd/iommu.c +++ b/arch/x86/events/amd/iommu.c @@ -379,7 +379,7 @@ static __init int _init_events_attrs(void) while (amd_iommu_v2_event_descs[i].attr.attr.name) i++; - attrs = kcalloc(i + 1, sizeof(struct attribute **), GFP_KERNEL); + attrs = kcalloc(i + 1, sizeof(*attrs), GFP_KERNEL); if (!attrs) return -ENOMEM;