ia64/xen-unstable

changeset 4203:6ac7c6ea6fc2

bitkeeper revision 1.1159.258.60 (423a9ce2eJtKIkEGHQPPRXvkPvoHqQ)

Check kmalloc return value in vbd code.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Mar 18 09:18:26 2005 +0000 (2005-03-18)
parents f7b65f70ccc8
children b31eaecb3354 e194000fb445 60fdb1da841d 92d8cf63dd24
files linux-2.6.11-xen-sparse/drivers/xen/blkfront/vbd.c
line diff
     1.1 --- a/linux-2.6.11-xen-sparse/drivers/xen/blkfront/vbd.c	Fri Mar 18 09:05:06 2005 +0000
     1.2 +++ b/linux-2.6.11-xen-sparse/drivers/xen/blkfront/vbd.c	Fri Mar 18 09:18:26 2005 +0000
     1.3 @@ -496,21 +496,16 @@ int xlvbd_init(void)
     1.4  {
     1.5      int i;
     1.6  
     1.7 -    /*
     1.8 -     * If compiled as a module, we don't support unloading yet. We
     1.9 -     * therefore permanently increment the reference count to
    1.10 -     * disallow it.
    1.11 -     */
    1.12 -    /* MOD_INC_USE_COUNT; */
    1.13 -
    1.14      memset(major_info, 0, sizeof(major_info));
    1.15  
    1.16 -    for (i = 0; i < sizeof(major_info) / sizeof(major_info[0]); i++) {
    1.17 +    vbd_info = kmalloc(MAX_VBDS * sizeof(vdisk_t), GFP_KERNEL);
    1.18 +    if (vbd_info == NULL) {
    1.19 +        printk(KERN_ALERT "Failed to allocate memory for disk info.\n");
    1.20 +        nr_vbds = 0;
    1.21 +        return 0;
    1.22      }
    1.23  
    1.24 -    vbd_info = kmalloc(MAX_VBDS * sizeof(vdisk_t), GFP_KERNEL);
    1.25      nr_vbds  = xlvbd_get_vbd_info(vbd_info);
    1.26 -
    1.27      if (nr_vbds < 0) {
    1.28          kfree(vbd_info);
    1.29          vbd_info = NULL;