diff options
author | Emil Goode <emilgoode@gmail.com> | 2012-08-20 14:32:25 -0400 |
---|---|---|
committer | Florian Tobias Schandinat <FlorianSchandinat@gmx.de> | 2012-09-22 17:16:20 -0400 |
commit | 58fc6ef6f8c8ae06a82f7dd3ae1fa09d4fcfc875 (patch) | |
tree | 53f5a9924c9f8245d849ec6dd9e298a9aafbdaa2 /drivers/video/hpfb.c | |
parent | bcfbeecea11c15e243f076d37d637c2598aff4fe (diff) |
video: hpfb: Fix error handling
This patch solves problems with the error handling by
introducing labels for proper error paths and it also
frees resources that where missed.
Signed-off-by: Emil Goode <emilgoode@gmail.com>
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Diffstat (limited to 'drivers/video/hpfb.c')
-rw-r--r-- | drivers/video/hpfb.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/drivers/video/hpfb.c b/drivers/video/hpfb.c index ebf8495ff198..7324865f965f 100644 --- a/drivers/video/hpfb.c +++ b/drivers/video/hpfb.c | |||
@@ -210,6 +210,7 @@ static int __devinit hpfb_init_one(unsigned long phys_base, | |||
210 | unsigned long virt_base) | 210 | unsigned long virt_base) |
211 | { | 211 | { |
212 | unsigned long fboff, fb_width, fb_height, fb_start; | 212 | unsigned long fboff, fb_width, fb_height, fb_start; |
213 | int ret; | ||
213 | 214 | ||
214 | fb_regs = virt_base; | 215 | fb_regs = virt_base; |
215 | fboff = (in_8(fb_regs + HPFB_FBOMSB) << 8) | in_8(fb_regs + HPFB_FBOLSB); | 216 | fboff = (in_8(fb_regs + HPFB_FBOMSB) << 8) | in_8(fb_regs + HPFB_FBOLSB); |
@@ -290,19 +291,29 @@ static int __devinit hpfb_init_one(unsigned long phys_base, | |||
290 | fb_info.var = hpfb_defined; | 291 | fb_info.var = hpfb_defined; |
291 | fb_info.screen_base = (char *)fb_start; | 292 | fb_info.screen_base = (char *)fb_start; |
292 | 293 | ||
293 | fb_alloc_cmap(&fb_info.cmap, 1 << hpfb_defined.bits_per_pixel, 0); | 294 | ret = fb_alloc_cmap(&fb_info.cmap, 1 << hpfb_defined.bits_per_pixel, 0); |
295 | if (ret < 0) | ||
296 | goto unmap_screen_base; | ||
294 | 297 | ||
295 | if (register_framebuffer(&fb_info) < 0) { | 298 | ret = register_framebuffer(&fb_info); |
296 | fb_dealloc_cmap(&fb_info.cmap); | 299 | if (ret < 0) |
297 | iounmap(fb_info.screen_base); | 300 | goto dealloc_cmap; |
298 | fb_info.screen_base = NULL; | ||
299 | return 1; | ||
300 | } | ||
301 | 301 | ||
302 | printk(KERN_INFO "fb%d: %s frame buffer device\n", | 302 | printk(KERN_INFO "fb%d: %s frame buffer device\n", |
303 | fb_info.node, fb_info.fix.id); | 303 | fb_info.node, fb_info.fix.id); |
304 | 304 | ||
305 | return 0; | 305 | return 0; |
306 | |||
307 | dealloc_cmap: | ||
308 | fb_dealloc_cmap(&fb_info.cmap); | ||
309 | |||
310 | unmap_screen_base: | ||
311 | if (fb_info.screen_base) { | ||
312 | iounmap(fb_info.screen_base); | ||
313 | fb_info.screen_base = NULL; | ||
314 | } | ||
315 | |||
316 | return ret; | ||
306 | } | 317 | } |
307 | 318 | ||
308 | /* | 319 | /* |
@@ -345,6 +356,9 @@ static void __devexit hpfb_remove_one(struct dio_dev *d) | |||
345 | if (d->scode >= DIOII_SCBASE) | 356 | if (d->scode >= DIOII_SCBASE) |
346 | iounmap((void *)fb_regs); | 357 | iounmap((void *)fb_regs); |
347 | release_mem_region(d->resource.start, resource_size(&d->resource)); | 358 | release_mem_region(d->resource.start, resource_size(&d->resource)); |
359 | fb_dealloc_cmap(&fb_info.cmap); | ||
360 | if (fb_info.screen_base) | ||
361 | iounmap(fb_info.screen_base); | ||
348 | } | 362 | } |
349 | 363 | ||
350 | static struct dio_device_id hpfb_dio_tbl[] = { | 364 | static struct dio_device_id hpfb_dio_tbl[] = { |