Commit 8770b268 authored by Konrad Rzeszutek Wilk's avatar Konrad Rzeszutek Wilk

Fix compile warnings: ignoring return value of 'xenbus_register_backend' ..

We neglect to check the return value of xenbus_register_backend
and take actions when that fails. This patch fixes that and adds
code to deal with those type of failures.
Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: default avatarJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
parent afd91d07
...@@ -614,6 +614,7 @@ static void make_response(blkif_t *blkif, u64 id, ...@@ -614,6 +614,7 @@ static void make_response(blkif_t *blkif, u64 id,
static int __init blkif_init(void) static int __init blkif_init(void)
{ {
int i, mmap_pages; int i, mmap_pages;
int rc = 0;
if (!xen_pv_domain()) if (!xen_pv_domain())
return -ENODEV; return -ENODEV;
...@@ -626,13 +627,17 @@ static int __init blkif_init(void) ...@@ -626,13 +627,17 @@ static int __init blkif_init(void)
mmap_pages, GFP_KERNEL); mmap_pages, GFP_KERNEL);
pending_pages = alloc_empty_pages_and_pagevec(mmap_pages); pending_pages = alloc_empty_pages_and_pagevec(mmap_pages);
if (!pending_reqs || !pending_grant_handles || !pending_pages) if (!pending_reqs || !pending_grant_handles || !pending_pages) {
rc = -ENOMEM;
goto out_of_memory; goto out_of_memory;
}
for (i = 0; i < mmap_pages; i++) for (i = 0; i < mmap_pages; i++)
pending_grant_handles[i] = BLKBACK_INVALID_HANDLE; pending_grant_handles[i] = BLKBACK_INVALID_HANDLE;
blkif_interface_init(); rc = blkif_interface_init();
if (rc)
goto failed_init;
memset(pending_reqs, 0, sizeof(pending_reqs)); memset(pending_reqs, 0, sizeof(pending_reqs));
INIT_LIST_HEAD(&pending_free); INIT_LIST_HEAD(&pending_free);
...@@ -640,16 +645,19 @@ static int __init blkif_init(void) ...@@ -640,16 +645,19 @@ static int __init blkif_init(void)
for (i = 0; i < blkif_reqs; i++) for (i = 0; i < blkif_reqs; i++)
list_add_tail(&pending_reqs[i].free_list, &pending_free); list_add_tail(&pending_reqs[i].free_list, &pending_free);
blkif_xenbus_init(); rc = blkif_xenbus_init();
if (rc)
goto failed_init;
return 0; return 0;
out_of_memory: out_of_memory:
printk(KERN_ERR "%s: out of memory\n", __func__);
failed_init:
kfree(pending_reqs); kfree(pending_reqs);
kfree(pending_grant_handles); kfree(pending_grant_handles);
free_empty_pages_and_pagevec(pending_pages, mmap_pages); free_empty_pages_and_pagevec(pending_pages, mmap_pages);
printk("%s: out of memory\n", __FUNCTION__); return rc;
return -ENOMEM;
} }
module_init(blkif_init); module_init(blkif_init);
......
...@@ -124,9 +124,9 @@ struct phys_req { ...@@ -124,9 +124,9 @@ struct phys_req {
int vbd_translate(struct phys_req *req, blkif_t *blkif, int operation); int vbd_translate(struct phys_req *req, blkif_t *blkif, int operation);
void blkif_interface_init(void); int blkif_interface_init(void);
void blkif_xenbus_init(void); int blkif_xenbus_init(void);
irqreturn_t blkif_be_int(int irq, void *dev_id); irqreturn_t blkif_be_int(int irq, void *dev_id);
int blkif_schedule(void *arg); int blkif_schedule(void *arg);
......
...@@ -175,8 +175,12 @@ void blkif_free(blkif_t *blkif) ...@@ -175,8 +175,12 @@ void blkif_free(blkif_t *blkif)
kmem_cache_free(blkif_cachep, blkif); kmem_cache_free(blkif_cachep, blkif);
} }
void __init blkif_interface_init(void) int __init blkif_interface_init(void)
{ {
blkif_cachep = kmem_cache_create("blkif_cache", sizeof(blkif_t), blkif_cachep = kmem_cache_create("blkif_cache", sizeof(blkif_t),
0, 0, NULL); 0, 0, NULL);
if (!blkif_cachep)
return -ENOMEM;
return 0;
} }
...@@ -535,8 +535,7 @@ static struct xenbus_driver blkback = { ...@@ -535,8 +535,7 @@ static struct xenbus_driver blkback = {
}; };
void blkif_xenbus_init(void) int blkif_xenbus_init(void)
{ {
/* XXX must_check */ return xenbus_register_backend(&blkback);
(void)xenbus_register_backend(&blkback);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment