[Intel-gfx] [PATCH 2/5] drm/i915: Use kcalloc more

Jani Nikula jani.nikula at linux.intel.com
Thu Sep 19 13:00:30 CEST 2013


On Thu, 19 Sep 2013, Chris Wilson <chris at chris-wilson.co.uk> wrote:
> On Thu, Sep 19, 2013 at 01:38:18PM +0300, Jani Nikula wrote:
>> On Thu, 19 Sep 2013, Daniel Vetter <daniel.vetter at ffwll.ch> wrote:
>> > diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c
>> > index c38d575..763283e 100644
>> > --- a/drivers/gpu/drm/i915/i915_gpu_error.c
>> > +++ b/drivers/gpu/drm/i915/i915_gpu_error.c
>> > @@ -791,7 +791,7 @@ static void i915_gem_record_rings(struct drm_device *dev,
>> >  
>> >  		error->ring[i].num_requests = count;
>> >  		error->ring[i].requests =
>> > -			kmalloc(count*sizeof(struct drm_i915_error_request),
>> > +			kcalloc(count, sizeof(error->ring[i].requests),
>> 
>> Crash boom bang.
>
> Not quite. This is evaluated at compile time by parsing the type rather
> than by pointer dereference.

Sizeof changes from sizeof(struct drm_i915_error_request) to
sizeof(struct drm_i915_error_request *). It'll break something. Maybe
not as spectacularly as I was implying.

Jani.


-- 
Jani Nikula, Intel Open Source Technology Center



More information about the Intel-gfx mailing list