On Thu, 12 May 2011 17:21:50 -0700, Keith Packard <[email protected]> wrote:
> On Thu, 12 May 2011 22:17:10 +0100, Chris Wilson <[email protected]> 
> wrote:
> 
> > +   pages = kmalloc(n*sizeof(struct page *),
> > +                   GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN);
> > +   if (pages == NULL) {
> > +           pages = drm_malloc_ab(n, sizeof(struct page *));
> > +           if (pages == NULL) {
> > +                   *pages_out = NULL;
> > +                   *num_pages = 0;
> > +                   return -ENOMEM;
> > +           }
> > +   }
> 
> Please use drm_malloc_ab here unconditionally;

We're not performing the same trick as drm_malloc_ab() here though, since
this is only used for a temporary allocation we try to consume any
high-order pages, rather than building an array of order-0 pages, knowing
that they will be released shortly afterwards.

> you've got a potential multiplication overflow,

Now this is more serious. Should we not just E2BIG any bo_create that will
require num_pages > MAXINT/sizeof(struct page*)? [1TiB on 32bit]
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to