* [PATCH][next] drm/i915/pmu: fix sizeof on attr, should be *attr
@ 2018-01-12 17:36 Colin King
2018-01-12 17:48 ` [Intel-gfx] " Tvrtko Ursulin
0 siblings, 1 reply; 3+ messages in thread
From: Colin King @ 2018-01-12 17:36 UTC (permalink / raw)
To: Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, David Airlie,
intel-gfx, dri-devel
Cc: kernel-janitors, linux-kernel
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.
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;
--
2.15.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Intel-gfx] [PATCH][next] drm/i915/pmu: fix sizeof on attr, should be *attr
2018-01-12 17:36 [PATCH][next] drm/i915/pmu: fix sizeof on attr, should be *attr Colin King
@ 2018-01-12 17:48 ` Tvrtko Ursulin
2018-01-12 18:08 ` Colin Ian King
0 siblings, 1 reply; 3+ messages in thread
From: Tvrtko Ursulin @ 2018-01-12 17:48 UTC (permalink / raw)
To: Colin King, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
David Airlie, intel-gfx, dri-devel
Cc: kernel-janitors, linux-kernel
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;
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Intel-gfx] [PATCH][next] drm/i915/pmu: fix sizeof on attr, should be *attr
2018-01-12 17:48 ` [Intel-gfx] " Tvrtko Ursulin
@ 2018-01-12 18:08 ` Colin Ian King
0 siblings, 0 replies; 3+ messages in thread
From: Colin Ian King @ 2018-01-12 18:08 UTC (permalink / raw)
To: Tvrtko Ursulin, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
David Airlie, intel-gfx, dri-devel
Cc: kernel-janitors, linux-kernel
On 12/01/18 17:48, Tvrtko Ursulin wrote:
>
> 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?
None that I know of.
>
> 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;
>>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-01-12 18:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-12 17:36 [PATCH][next] drm/i915/pmu: fix sizeof on attr, should be *attr Colin King
2018-01-12 17:48 ` [Intel-gfx] " Tvrtko Ursulin
2018-01-12 18:08 ` Colin Ian King
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox