Re: [PATCH 2/5] drm/i915: Use kcalloc more

Chris Wilson
2013-09-19T11:12:05Z

On Thu, Sep 19, 2013 at 02:00:30PM +0300, Jani Nikula wrote:
> On Thu, 19 Sep 2013, Chris Wilson <chris@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@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.

Apologies, I automatically go into CLANG is a not a valid C compiler
mode...

sizeof(*error->ring[i].requests)
-Chris

--
Chris Wilson, Intel Open Source Technology Centre