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

Chris Wilson chris at chris-wilson.co.uk
Thu Sep 19 14:41:53 CEST 2013


On Thu, Sep 19, 2013 at 02:35:42PM +0200, Daniel Vetter wrote:
> On Thu, Sep 19, 2013 at 2:30 PM, Chris Wilson <chris at chris-wilson.co.uk> wrote:
> > On Thu, Sep 19, 2013 at 02:06:39PM +0200, Daniel Vetter wrote:
> >> No buffer overflows here, but better safe than sorry.
> >>
> >> v2:
> >> - Fixup the sizeof conversion, I've missed the pointer deref (Jani).
> >> - Drop the redundant GFP_ZERO, kcalloc alreads memsets (Jani).
> >> - Use kmalloc_array for the execbuf fastpath to avoid the memset
> >>   (Chris). I've opted to leave all other conversions as-is since they
> >>   aren't in a fastpath and dealing with cleared memory instead of
> >>   random garbage is just generally nicer.
> >
> > I still don't agree with this change to kmalloc_array. The code is
> > written explicitly such that an invalid buffer_count is reported as
> > EINVAL and not ENOMEM.
> 
> It's just paranoia - imo consistently using kcalloc/kmalloc array
> where possible is just safer. Note also that the subtest I've added
> explicitly checks for EINVAL, so if we ever botch this it should get
> caught.

Paranoia for what? Checking the same thing twice in case the compiler
changes it mind?
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre



More information about the Intel-gfx mailing list