UPSTREAM: drm/rockchip: fix wrong pitch/size using on gem
authorMark Yao <mark.yao@rock-chips.com>
Wed, 23 Sep 2015 04:34:34 +0000 (12:34 +0800)
committerMark Yao <mark.yao@rock-chips.com>
Thu, 17 Mar 2016 01:42:06 +0000 (09:42 +0800)
commitc9d0bdaa2b6ee9a30a6fd2e8da69d3a72c051bf1
tree5706ef97b165b9fa1953dbfedd2c86dbda82f8ca
parentc1dc2dc56801277d57a73f7ecc223fc87e2408af
UPSTREAM: drm/rockchip: fix wrong pitch/size using on gem

args->pitch and args->size may not be set by userspace, sometimes
userspace only malloc args and not memset args to zero, then
args->pitch and args->size is random, it is very danger to use
pitch/size on gem.

pitch's type is u32, and min_pitch's type is int, example,
pitch is 0xffffffff, then pitch < min_pitch return true, then gem will
alloc very very big bufffer, it would eat all the memory and cause kernel
crash.

Stop using pitch/size from args, calc them from other args.

Change-Id: I867d61bf6bc48a2989ae4d15a819a85a7e38d26f
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
(cherry picked from commit e3c4abdb3bc9b76bedd416ecc5c27633a2f8afed)
drivers/gpu/drm/rockchip/rockchip_drm_gem.c