Skip to content

Commit

Permalink
drivers/video/xen-fbfront.c: add missing cleanup code
Browse files Browse the repository at this point in the history
The operations in the subsequent error-handling code appear to be also
useful here.

Acked-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
[v1: Collapse some of the error handling functions]
[v2: Fix compile warning]
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
  • Loading branch information
Julia Lawall authored and Konrad Rzeszutek Wilk committed May 7, 2012
1 parent 7eb7ce4 commit a7a97c6
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions drivers/video/xen-fbfront.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ static int __devinit xenfb_probe(struct xenbus_device *dev,
struct fb_info *fb_info;
int fb_size;
int val;
int ret;
int ret = 0;

info = kzalloc(sizeof(*info), GFP_KERNEL);
if (info == NULL) {
Expand Down Expand Up @@ -458,26 +458,31 @@ static int __devinit xenfb_probe(struct xenbus_device *dev,
xenfb_init_shared_page(info, fb_info);

ret = xenfb_connect_backend(dev, info);
if (ret < 0)
goto error;
if (ret < 0) {
xenbus_dev_fatal(dev, ret, "xenfb_connect_backend");
goto error_fb;
}

ret = register_framebuffer(fb_info);
if (ret) {
fb_deferred_io_cleanup(fb_info);
fb_dealloc_cmap(&fb_info->cmap);
framebuffer_release(fb_info);
xenbus_dev_fatal(dev, ret, "register_framebuffer");
goto error;
goto error_fb;
}
info->fb_info = fb_info;

xenfb_make_preferred_console();
return 0;

error_nomem:
ret = -ENOMEM;
xenbus_dev_fatal(dev, ret, "allocating device memory");
error:
error_fb:
fb_deferred_io_cleanup(fb_info);
fb_dealloc_cmap(&fb_info->cmap);
framebuffer_release(fb_info);
error_nomem:
if (!ret) {
ret = -ENOMEM;
xenbus_dev_fatal(dev, ret, "allocating device memory");
}
error:
xenfb_remove(dev);
return ret;
}
Expand Down

0 comments on commit a7a97c6

Please sign in to comment.