Re: [PATCH 1/2] drm: replace drm_[cm]alloc* by kvmalloc alternatives

From: Michal Hocko
Date: Wed May 17 2017 - 05:23:55 EST


On Wed 17-05-17 10:12:41, Chris Wilson wrote:
> On Wed, May 17, 2017 at 11:03:50AM +0200, Michal Hocko wrote:
[...]
> > +static inline bool alloc_array_check(size_t n, size_t size)
> > +{
> > + if (size != 0 && n > SIZE_MAX / size)
> > + return false;
> > + return true;
>
> Just return size == 0 || n <= SIZE_MAX /size ?
>
> Whether or not size being 0 makes for a sane user is another question.
> The guideline is that size is the known constant from sizeof() or
> whatever and n is the variable number to allocate.
>
> But yes, that inline is what I want :)

I will think about this. Maybe it will help to simplify/unify some other
users. Do you have any pointers to save me some grepping...?

--
Michal Hocko
SUSE Labs