All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: "Chris Wilson" <chris@chris-wilson.co.uk>,
	"Michał Winiarski" <michal.winiarski@intel.com>,
	intel-gfx@lists.freedesktop.org,
	"Daniel Vetter" <daniel@ffwll.ch>,
	"Mika Kuoppala" <mika.kuoppala@linux.intel.com>,
	"Michel Thierry" <michel.thierry@intel.com>
Subject: Re: [PATCH v5] drm/i915/gtt: Avoid calling kcalloc in a loop when allocating temp bitmaps
Date: Fri, 4 Sep 2015 09:53:58 +0200	[thread overview]
Message-ID: <20150904075358.GG22430@phenom.ffwll.local> (raw)
In-Reply-To: <20150903204803.GL2808@nuc-i3427.alporthouse.com>

On Thu, Sep 03, 2015 at 09:48:03PM +0100, Chris Wilson wrote:
> On Thu, Sep 03, 2015 at 07:22:18PM +0200, Michał Winiarski wrote:
> > +	pts = kcalloc(pdpes * BITS_TO_LONGS(I915_PDES),
> > +		      sizeof(unsigned long), GFP_TEMPORARY);
> 
> Something to remember is that kcalloc is written presuming that the size
> argument (the second) is constant.
> 
> pts = kcalloc(pdpes,
> 	      BITS_TO_LONGS(I915_PDES) * sizeof(unsigned long),
> 	      GFP_TEMPORARY);
> 
> should be infinitesimally more efficient.

That's also better style from a security pov sinc kcalloc checks for
overflows. Which means if you multiply yourself things might overflow and
go boom. Luckily pdpdes is guaranteed to be small enough here, but still
secure coding best practices means you better not multiply the variable.
Hence I changed this.

> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>

Queued for -next, thanks for the patch.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

      reply	other threads:[~2015-09-04  7:51 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-31 16:27 [PATCH] drm/i915/gtt: Avoid calling kcalloc in a loop when allocating temp bitmaps Michał Winiarski
2015-08-31 16:40 ` Chris Wilson
2015-08-31 16:59 ` [PATCH v2] " Michał Winiarski
2015-08-31 18:42   ` Chris Wilson
2015-09-01  9:03     ` Michał Winiarski
2015-09-01  9:06   ` [PATCH v3] " Michał Winiarski
2015-09-02 13:40     ` Michel Thierry
2015-09-02 13:46       ` Chris Wilson
2015-09-02 15:13         ` Daniel Vetter
2015-09-02 15:26           ` Daniel Vetter
2015-09-02 15:46             ` [PATCH v4] " Michał Winiarski
2015-09-02 16:05               ` Chris Wilson
2015-09-03 17:22               ` [PATCH v5] " Michał Winiarski
2015-09-03 20:48                 ` Chris Wilson
2015-09-04  7:53                   ` Daniel Vetter [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150904075358.GG22430@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=michal.winiarski@intel.com \
    --cc=michel.thierry@intel.com \
    --cc=mika.kuoppala@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.