drm: fix division-by-zero on dumb_create()
authorDavid Herrmann <dh.herrmann@gmail.com>
Sun, 24 Aug 2014 17:23:26 +0000 (19:23 +0200)
committerDave Airlie <airlied@redhat.com>
Thu, 28 Aug 2014 01:38:04 +0000 (11:38 +1000)
commit00e7208997d7a42b6f7b22f582523755f43a2f9b
treef78c53805cf874e597290c8feaa4bb7282e669bb
parent4d6923733f158e7f8f0695b43c30c22a59ec0a34
drm: fix division-by-zero on dumb_create()

Kinda unexpected, but DIV_ROUND_UP() can overflow if passed an argument
bigger than UINT_MAX - DIVISOR. Fix this by testing for "!cpp" before
using it in the following division.

Note that DIV_ROUND_UP() is defined as:
        #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))

..this will obviously overflow if (n + d - 1) is bigger than UINT_MAX.

Reported-by: Tommi Rantala <tt.rantala@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Reviewed-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/drm_crtc.c