diff options
-rw-r--r-- | drivers/video/fbcmap.c | 54 |
1 files changed, 30 insertions, 24 deletions
diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c index f53b9f1d6aba..a79b9762901e 100644 --- a/drivers/video/fbcmap.c +++ b/drivers/video/fbcmap.c | |||
@@ -90,32 +90,38 @@ static const struct fb_cmap default_16_colors = { | |||
90 | 90 | ||
91 | int fb_alloc_cmap(struct fb_cmap *cmap, int len, int transp) | 91 | int fb_alloc_cmap(struct fb_cmap *cmap, int len, int transp) |
92 | { | 92 | { |
93 | int size = len*sizeof(u16); | 93 | int size = len * sizeof(u16); |
94 | 94 | ||
95 | if (cmap->len != len) { | 95 | if (cmap->len != len) { |
96 | fb_dealloc_cmap(cmap); | 96 | fb_dealloc_cmap(cmap); |
97 | if (!len) | 97 | if (!len) |
98 | return 0; | 98 | return 0; |
99 | if (!(cmap->red = kmalloc(size, GFP_ATOMIC))) | 99 | |
100 | goto fail; | 100 | cmap->red = kmalloc(size, GFP_ATOMIC); |
101 | if (!(cmap->green = kmalloc(size, GFP_ATOMIC))) | 101 | if (!cmap->red) |
102 | goto fail; | 102 | goto fail; |
103 | if (!(cmap->blue = kmalloc(size, GFP_ATOMIC))) | 103 | cmap->green = kmalloc(size, GFP_ATOMIC); |
104 | goto fail; | 104 | if (!cmap->green) |
105 | if (transp) { | 105 | goto fail; |
106 | if (!(cmap->transp = kmalloc(size, GFP_ATOMIC))) | 106 | cmap->blue = kmalloc(size, GFP_ATOMIC); |
107 | goto fail; | 107 | if (!cmap->blue) |
108 | } else | 108 | goto fail; |
109 | cmap->transp = NULL; | 109 | if (transp) { |
110 | } | 110 | cmap->transp = kmalloc(size, GFP_ATOMIC); |
111 | cmap->start = 0; | 111 | if (!cmap->transp) |
112 | cmap->len = len; | 112 | goto fail; |
113 | fb_copy_cmap(fb_default_cmap(len), cmap); | 113 | } else { |
114 | return 0; | 114 | cmap->transp = NULL; |
115 | } | ||
116 | } | ||
117 | cmap->start = 0; | ||
118 | cmap->len = len; | ||
119 | fb_copy_cmap(fb_default_cmap(len), cmap); | ||
120 | return 0; | ||
115 | 121 | ||
116 | fail: | 122 | fail: |
117 | fb_dealloc_cmap(cmap); | 123 | fb_dealloc_cmap(cmap); |
118 | return -ENOMEM; | 124 | return -ENOMEM; |
119 | } | 125 | } |
120 | 126 | ||
121 | /** | 127 | /** |