Ignore:
Timestamp:
Apr 16, 2017, 3:07:01 PM (3 months ago)
Author:
brainslayer
Message:

update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/linux/universal/linux-3.18/drivers/video/fbdev/core/fbcmap.c

    r25370 r31869  
    164164int fb_copy_cmap(const struct fb_cmap *from, struct fb_cmap *to)
    165165{
    166         int tooff = 0, fromoff = 0;
    167         int size;
     166        unsigned int tooff = 0, fromoff = 0;
     167        size_t size;
    168168
    169169        if (to->start > from->start)
     
    171171        else
    172172                tooff = from->start - to->start;
    173         size = to->len - tooff;
    174         if (size > (int) (from->len - fromoff))
    175                 size = from->len - fromoff;
    176         if (size <= 0)
     173        if (fromoff >= from->len || tooff >= to->len)
     174                return -EINVAL;
     175
     176        size = min_t(size_t, to->len - tooff, from->len - fromoff);
     177        if (size == 0)
    177178                return -EINVAL;
    178179        size *= sizeof(u16);
     
    188189int fb_cmap_to_user(const struct fb_cmap *from, struct fb_cmap_user *to)
    189190{
    190         int tooff = 0, fromoff = 0;
    191         int size;
     191        unsigned int tooff = 0, fromoff = 0;
     192        size_t size;
    192193
    193194        if (to->start > from->start)
     
    195196        else
    196197                tooff = from->start - to->start;
    197         size = to->len - tooff;
    198         if (size > (int) (from->len - fromoff))
    199                 size = from->len - fromoff;
    200         if (size <= 0)
     198        if (fromoff >= from->len || tooff >= to->len)
     199                return -EINVAL;
     200
     201        size = min_t(size_t, to->len - tooff, from->len - fromoff);
     202        if (size == 0)
    201203                return -EINVAL;
    202204        size *= sizeof(u16);
Note: See TracChangeset for help on using the changeset viewer.