From patchwork Thu Jun 7 14:57:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10452531 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 85D7660234 for ; Thu, 7 Jun 2018 14:57:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7223A29625 for ; Thu, 7 Jun 2018 14:57:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 66F6C2963B; Thu, 7 Jun 2018 14:57:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC8C929625 for ; Thu, 7 Jun 2018 14:57:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6263D6B02AB; Thu, 7 Jun 2018 10:57:29 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 283BC6B02A8; Thu, 7 Jun 2018 10:57:29 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 082996B02A9; Thu, 7 Jun 2018 10:57:28 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f197.google.com (mail-pf0-f197.google.com [209.85.192.197]) by kanga.kvack.org (Postfix) with ESMTP id 8F17B6B02A4 for ; Thu, 7 Jun 2018 10:57:28 -0400 (EDT) Received: by mail-pf0-f197.google.com with SMTP id j25-v6so3562768pfi.9 for ; Thu, 07 Jun 2018 07:57:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=ddaQmGfdRo8pmT21eJd+HFHksxfrWFcXQbUE0j4Hyz0=; b=GBtdhd7yAfu+N5saQK2yMztSaHVOg7sbZlpdDEWNcuhYSqqDVgdPKDkDkSY5MJ2yU3 ED6FT77MVmTFMka5olH38jbwI8fafpg8tjFty0aKREASJZhN7p2Ee6npDUulcW8icfMn 3pzdJTsO+DSKEXuOTVYsFBenTd40c4WsqBaabRZG7QSbR5jSjcAIUSaEnHDuamVrN8cl WSeYI8wzMZihP7xpAeqOxAqbgltpCoL8wh/szTes8jK28NNcEwLBNRNqEenGHqeCfnn3 QYeD19OgYCxzWEKEpNHjEYBLNIFCvB1YddJKnQ6u9p+umhxP0chMlvvC8vTD6STOgIPe UCEg== X-Gm-Message-State: APt69E3etjoOj+O+2q/XJ7/r30jGBKDbWZcaxpWwIN4/btTcUt6FL7+M VFFmBNOEVRdmodTZTUhh0t4Cs/zSLh86QYyjczEADCswz79HB7s9zbkvIRPb24NT0wJoBQ6D9ra Z+4reaBtre1Pw8b4K/y6xL7chvjleH/cdLsj5+PHAPRSMgJ5GmlzNAEnQPqpfg2BINw== X-Received: by 2002:a17:902:6a89:: with SMTP id n9-v6mr2358818plk.302.1528383448287; Thu, 07 Jun 2018 07:57:28 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLnxymMtX+ultQETmHDZZ1rTD/FFuq3mYkwMSGliHIbGpDqWJ316aGmb2Hvw0R7rnNOSKU6 X-Received: by 2002:a17:902:6a89:: with SMTP id n9-v6mr2358766plk.302.1528383447056; Thu, 07 Jun 2018 07:57:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528383447; cv=none; d=google.com; s=arc-20160816; b=OMPcX49xQv233bsBgsTDamdU/rgLzHJre7CGSeAfhYQqKDHRj1e6O3ASfY/BteqfnP 5MVTiklj2ovIj1ngyrtiX8KLx5rUFI10O9LtSerPsySa7P0BHAI8OeFiMnENL+Pg17GF ESRhg6HRC5Vyr3uXcHgWfEE22VcvQBE1CWXOio6zQfN4ygy00OtOk6OiJE4cIVLsJCej XvZmTekWDXtt5TRKMU+GNzACCsH6XTkKYsvT8nE7Ada/1kb3aaEvRyfaY+uDtv4l1eXA f8pNmBsMgVVIbY1HUHe5eirCDLlYTC1zia81rTqKFSIWbL9XEGnARVC+l6D4e59tmSpP 5g7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=ddaQmGfdRo8pmT21eJd+HFHksxfrWFcXQbUE0j4Hyz0=; b=LIf2p25nl6Ioe5FjYwWvHsPltWKk+aozu+GWOBcz2S1enW2fBeUW62YQEZ9j6jUaGO Yosz9WjawrdJZB2tjbi3J3tPCP7qLyQ9mxXATf97fz8N3FZ/FsjPHa1fmZyMwSLY+hS9 8wuMiH7yPGdTfulgImJGVmxeqzxdFEe6FY1sUTRl6tG8rOIKKliXm9NwAXE3ADh6g9Xu yscmBRuSMEQAe2h003PUHJLaNW+DIIjd1lVsnmwuDMaryeolaEJADqmFqCSNJCrwIIa9 hpUV9I0lD7mnLkKn/F4XICvw0j3YY+SAYgST8mPBUzBPcTRqU72Y1wGJk0hFCoHQekdL VGNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=RcEPVec9; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id v1-v6si1825227ply.458.2018.06.07.07.57.26 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Jun 2018 07:57:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=RcEPVec9; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ddaQmGfdRo8pmT21eJd+HFHksxfrWFcXQbUE0j4Hyz0=; b=RcEPVec9nSkmZukf5BftLiGCO rAqU67RUxazRuJZAK2jIdf7fBM8mtpCiCuGWRBgcK0kza1gaohoBFuaAFnJtgw2tnO83+dS8nOlNN EjKQ4KBC1xRGcnyNUupBp0yLqc/pXKym4/czkJ3ioZIhaNNbeAnFeh1ve8TRyW3yyiU1+F4Qxc/b7 7MQtpRGGAQPFWVftkmIp5snVIPSjTNLkf2cv59jNtwHVa71AiTateomSDcbei7LB/gUYMskSdUN1L av9SNUZ6LZmWyZYoC4bmluYU8vfu8Zprf5sp6OZj9JvART86uzcGOnSKgZTFTXcYmM2ccCsuTp5AO nCgxzVLTw==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fQwLt-0005uD-RG; Thu, 07 Jun 2018 14:57:25 +0000 From: Matthew Wilcox To: Kees Cook Cc: Matthew Wilcox , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Subject: [PATCH 6/6] Convert intel uncore to struct_size Date: Thu, 7 Jun 2018 07:57:20 -0700 Message-Id: <20180607145720.22590-7-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180607145720.22590-1-willy@infradead.org> References: <20180607145720.22590-1-willy@infradead.org> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Matthew Wilcox Need to do a bit of rearranging to make this work. Signed-off-by: Matthew Wilcox --- arch/x86/events/intel/uncore.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c index 15b07379e72d..e15cfad4f89b 100644 --- a/arch/x86/events/intel/uncore.c +++ b/arch/x86/events/intel/uncore.c @@ -865,8 +865,6 @@ static void uncore_types_exit(struct intel_uncore_type **types) static int __init uncore_type_init(struct intel_uncore_type *type, bool setid) { struct intel_uncore_pmu *pmus; - struct attribute_group *attr_group; - struct attribute **attrs; size_t size; int i, j; @@ -891,21 +889,24 @@ static int __init uncore_type_init(struct intel_uncore_type *type, bool setid) 0, type->num_counters, 0, 0); if (type->event_descs) { + struct { + struct attribute_group group; + struct attribute *attrs[]; + } *attr_group; for (i = 0; type->event_descs[i].attr.attr.name; i++); - attr_group = kzalloc(sizeof(struct attribute *) * (i + 1) + - sizeof(*attr_group), GFP_KERNEL); + attr_group = kzalloc(struct_size(attr_group, attrs, i + 1), + GFP_KERNEL); if (!attr_group) goto err; - attrs = (struct attribute **)(attr_group + 1); - attr_group->name = "events"; - attr_group->attrs = attrs; + attr_group->group.name = "events"; + attr_group->group.attrs = attr_group->attrs; for (j = 0; j < i; j++) - attrs[j] = &type->event_descs[j].attr.attr; + attr_group->attrs[j] = &type->event_descs[j].attr.attr; - type->events_group = attr_group; + type->events_group = &attr_group->group; } type->pmu_group = &uncore_pmu_attr_group;