LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Ralph Campbell <rcampbell@nvidia.com>
To: Matthew Wilcox <willy@infradead.org>, Kees Cook <keescook@chromium.org>
Cc: Matthew Wilcox <mawilcox@microsoft.com>, <linux-mm@kvack.org>,
	<linux-kernel@vger.kernel.org>,
	<kernel-hardening@lists.openwall.com>
Subject: Re: [PATCH 6/6] Convert intel uncore to struct_size
Date: Thu, 7 Jun 2018 10:29:49 -0700	[thread overview]
Message-ID: <03d9addb-9c68-c6e5-d7db-57468fc3950c@nvidia.com> (raw)
In-Reply-To: <20180607145720.22590-7-willy@infradead.org>



On 06/07/2018 07:57 AM, Matthew Wilcox wrote:
> From: Matthew Wilcox <mawilcox@microsoft.com>
> 
> Need to do a bit of rearranging to make this work.
> 
> Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
> ---
>   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++);

What does this for loop do?
Looks like nothing given the semicolon at the end.

> -		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;
> 

  reply	other threads:[~2018-06-07 17:29 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-07 14:57 [PATCH 0/6] More conversions " Matthew Wilcox
2018-06-07 14:57 ` [PATCH 1/6] Convert virtio_console " Matthew Wilcox
2018-06-07 19:29   ` Kees Cook
2018-06-07 20:43     ` Kees Cook
2018-06-07 14:57 ` [PATCH 2/6] Convert infiniband uverbs " Matthew Wilcox
2018-06-07 14:57 ` [PATCH 3/6] Convert v4l2 event " Matthew Wilcox
2018-06-08  4:03   ` kbuild test robot
2018-06-07 14:57 ` [PATCH 4/6] Convert vhost " Matthew Wilcox
2018-06-07 14:57 ` [PATCH 5/6] Convert jffs2 acl " Matthew Wilcox
2018-06-07 14:57 ` [PATCH 6/6] Convert intel uncore " Matthew Wilcox
2018-06-07 17:29   ` Ralph Campbell [this message]
2018-06-07 17:34     ` Shakeel Butt
2018-06-08  4:03   ` kbuild test robot
2018-06-08  4:09   ` kbuild test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=03d9addb-9c68-c6e5-d7db-57468fc3950c@nvidia.com \
    --to=rcampbell@nvidia.com \
    --cc=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mawilcox@microsoft.com \
    --cc=willy@infradead.org \
    --subject='Re: [PATCH 6/6] Convert intel uncore to struct_size' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).