Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1643172
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 1/2] drm: replace drm_[cm]alloc* by kvmalloc alternatives |
| Date | 2017-05-17 11:30 +0200 |
| Message-ID | <tI3rj-1fU-9@gated-at.bofh.it> (permalink) |
| References | <tI169-86C-11@gated-at.bofh.it> <tI1Sy-ck-11@gated-at.bofh.it> <tI37Y-19V-11@gated-at.bofh.it> <tI3hE-1cV-21@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH 1/2] drm: replace drm_[cm]alloc* by kvmalloc alternatives Michal Hocko <mhocko@kernel.org> - 2017-05-17 09:00 +0200
Re: [PATCH 1/2] drm: replace drm_[cm]alloc* by kvmalloc alternatives Chris Wilson <chris@chris-wilson.co.uk> - 2017-05-17 09:50 +0200
Re: [PATCH 1/2] drm: replace drm_[cm]alloc* by kvmalloc alternatives Michal Hocko <mhocko@kernel.org> - 2017-05-17 11:10 +0200
Re: [PATCH 1/2] drm: replace drm_[cm]alloc* by kvmalloc alternatives Chris Wilson <chris@chris-wilson.co.uk> - 2017-05-17 11:20 +0200
Re: [PATCH 1/2] drm: replace drm_[cm]alloc* by kvmalloc alternatives Michal Hocko <mhocko@kernel.org> - 2017-05-17 11:30 +0200
csiph-web