From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Colin King <colin.king@canonical.com>,
Jani Nikula <jani.nikula@linux.intel.com>,
Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
David Airlie <airlied@linux.ie>,
intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [Intel-gfx] [PATCH][next] drm/i915/pmu: fix sizeof on attr, should be *attr
Date: Fri, 12 Jan 2018 17:48:57 +0000 [thread overview]
Message-ID: <1465951f-474c-e157-892b-33d12ad436cb@linux.intel.com> (raw)
In-Reply-To: <20180112173603.28486-1-colin.king@canonical.com>
Hi,
On 12/01/2018 17:36, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> I believe the sizeof(attr) should be in fact sizeof(*attr), fortunately
> the current code works because sizeof(struct attribute **) is the same
> as sizeof(struct attribute *) for x86.
Thanks, kbuild also reported it and I just pushed a fix.
Out of curiosity, there are platforms where size of pointer is different
from the size of a pointer to a pointer?
Regards,
Tvrtko
>
> Detected by CoverityScan, CID#1463854 ("Sizeof not portable")
>
> Fixes: 109ec558370f ("drm/i915/pmu: Only enumerate available counters in sysfs")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/gpu/drm/i915/i915_pmu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c
> index 95ab5e28f5be..9be4f5201e41 100644
> --- a/drivers/gpu/drm/i915/i915_pmu.c
> +++ b/drivers/gpu/drm/i915/i915_pmu.c
> @@ -794,7 +794,7 @@ create_event_attributes(struct drm_i915_private *i915)
> goto err_alloc;
>
> /* Max one pointer of each attribute type plus a termination entry. */
> - attr = kzalloc((count * 2 + 1) * sizeof(attr), GFP_KERNEL);
> + attr = kzalloc((count * 2 + 1) * sizeof(*attr), GFP_KERNEL);
> if (!attr)
> goto err_alloc;
>
>
WARNING: multiple messages have this Message-ID (diff)
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Colin King <colin.king@canonical.com>,
Jani Nikula <jani.nikula@linux.intel.com>,
Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
David Airlie <airlied@linux.ie>,
intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH][next] drm/i915/pmu: fix sizeof on attr, should be *attr
Date: Fri, 12 Jan 2018 17:48:57 +0000 [thread overview]
Message-ID: <1465951f-474c-e157-892b-33d12ad436cb@linux.intel.com> (raw)
In-Reply-To: <20180112173603.28486-1-colin.king@canonical.com>
Hi,
On 12/01/2018 17:36, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> I believe the sizeof(attr) should be in fact sizeof(*attr), fortunately
> the current code works because sizeof(struct attribute **) is the same
> as sizeof(struct attribute *) for x86.
Thanks, kbuild also reported it and I just pushed a fix.
Out of curiosity, there are platforms where size of pointer is different
from the size of a pointer to a pointer?
Regards,
Tvrtko
>
> Detected by CoverityScan, CID#1463854 ("Sizeof not portable")
>
> Fixes: 109ec558370f ("drm/i915/pmu: Only enumerate available counters in sysfs")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/gpu/drm/i915/i915_pmu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c
> index 95ab5e28f5be..9be4f5201e41 100644
> --- a/drivers/gpu/drm/i915/i915_pmu.c
> +++ b/drivers/gpu/drm/i915/i915_pmu.c
> @@ -794,7 +794,7 @@ create_event_attributes(struct drm_i915_private *i915)
> goto err_alloc;
>
> /* Max one pointer of each attribute type plus a termination entry. */
> - attr = kzalloc((count * 2 + 1) * sizeof(attr), GFP_KERNEL);
> + attr = kzalloc((count * 2 + 1) * sizeof(*attr), GFP_KERNEL);
> if (!attr)
> goto err_alloc;
>
>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2018-01-12 17:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-12 17:36 [PATCH][next] drm/i915/pmu: fix sizeof on attr, should be *attr Colin King
2018-01-12 17:36 ` Colin King
2018-01-12 17:48 ` Tvrtko Ursulin [this message]
2018-01-12 17:48 ` Tvrtko Ursulin
2018-01-12 18:08 ` [Intel-gfx] " Colin Ian King
2018-01-12 18:08 ` Colin Ian King
2018-01-12 17:57 ` ✓ Fi.CI.BAT: success for " Patchwork
2018-01-12 19:28 ` ✗ Fi.CI.IGT: failure " Patchwork
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=1465951f-474c-e157-892b-33d12ad436cb@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=airlied@linux.ie \
--cc=colin.king@canonical.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rodrigo.vivi@intel.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.