aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/fbcmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/video/fbcmap.c')
-rw-r--r--drivers/video/fbcmap.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
index 91b78e691505..f53b9f1d6aba 100644
--- a/drivers/video/fbcmap.c
+++ b/drivers/video/fbcmap.c
@@ -250,10 +250,6 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
250 int rc, size = cmap->len * sizeof(u16); 250 int rc, size = cmap->len * sizeof(u16);
251 struct fb_cmap umap; 251 struct fb_cmap umap;
252 252
253 if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
254 !info->fbops->fb_setcmap))
255 return -EINVAL;
256
257 memset(&umap, 0, sizeof(struct fb_cmap)); 253 memset(&umap, 0, sizeof(struct fb_cmap));
258 rc = fb_alloc_cmap(&umap, cmap->len, cmap->transp != NULL); 254 rc = fb_alloc_cmap(&umap, cmap->len, cmap->transp != NULL);
259 if (rc) 255 if (rc)
@@ -262,11 +258,23 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
262 copy_from_user(umap.green, cmap->green, size) || 258 copy_from_user(umap.green, cmap->green, size) ||
263 copy_from_user(umap.blue, cmap->blue, size) || 259 copy_from_user(umap.blue, cmap->blue, size) ||
264 (cmap->transp && copy_from_user(umap.transp, cmap->transp, size))) { 260 (cmap->transp && copy_from_user(umap.transp, cmap->transp, size))) {
265 fb_dealloc_cmap(&umap); 261 rc = -EFAULT;
266 return -EFAULT; 262 goto out;
267 } 263 }
268 umap.start = cmap->start; 264 umap.start = cmap->start;
265 if (!lock_fb_info(info)) {
266 rc = -ENODEV;
267 goto out;
268 }
269 if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
270 !info->fbops->fb_setcmap)) {
271 rc = -EINVAL;
272 goto out1;
273 }
269 rc = fb_set_cmap(&umap, info); 274 rc = fb_set_cmap(&umap, info);
275out1:
276 unlock_fb_info(info);
277out:
270 fb_dealloc_cmap(&umap); 278 fb_dealloc_cmap(&umap);
271 return rc; 279 return rc;
272} 280}