drivers: video: Add bounds checking in fb_cmap_to_user

Verify that unsigned int value will not become negative before cast to
signed int.

Bug: 31651010
Change-Id: I548a200f678762042617f11100b6966a405a3920
This commit is contained in:
Steve Pfetsch 2016-10-14 15:36:59 -07:00 committed by Simon Shields
parent 1180db142c
commit d39b8b9e21

View file

@ -196,7 +196,7 @@ int fb_cmap_to_user(const struct fb_cmap *from, struct fb_cmap_user *to)
int tooff = 0, fromoff = 0;
int size;
if (!to || !from)
if (!to || !from || (int)(to->start) < 0)
return -EINVAL;
if (to->start > from->start)