WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [Patch xen-unstable] mem alloc handling in xlvbd_init()

To: xen-devel@xxxxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [Patch xen-unstable] mem alloc handling in xlvbd_init()
From: Nivedita Singhvi <niv@xxxxxxxxxx>
Date: Thu, 17 Mar 2005 15:53:38 -0800
Delivery-date: Fri, 18 Mar 2005 00:12:47 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <s239aff2.084@xxxxxxxxxxxxxxxxxxxxxxxxx>
List-archive: <http://sourceforge.net/mailarchive/forum.php?forum=xen-devel>
List-help: <mailto:xen-devel-request@lists.sourceforge.net?subject=help>
List-id: List for Xen developers <xen-devel.lists.sourceforge.net>
List-post: <mailto:xen-devel@lists.sourceforge.net>
List-subscribe: <https://lists.sourceforge.net/lists/listinfo/xen-devel>, <mailto:xen-devel-request@lists.sourceforge.net?subject=subscribe>
List-unsubscribe: <https://lists.sourceforge.net/lists/listinfo/xen-devel>, <mailto:xen-devel-request@lists.sourceforge.net?subject=unsubscribe>
References: <s239aff2.084@xxxxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-admin@xxxxxxxxxxxxxxxxxxxxx
User-agent: Mozilla Thunderbird 0.9 (X11/20041127)
Minor nit: would be nice to die gracefully if we fail
to allocate memory in xlvbd_init() instead of blowing
up in xlvbd_get_vbd_info().

thanks,
Nivedita


diff -urN linux-2.6.11-xen-sparse/drivers/xen/blkfront/vbd.c 
linux-2.6.11-xen-sparse.new/drivers/xen/blkfront/vbd.c
--- linux-2.6.11-xen-sparse/drivers/xen/blkfront/vbd.c  2005-03-14 
20:18:19.000000000 -0800
+++ linux-2.6.11-xen-sparse.new/drivers/xen/blkfront/vbd.c      2005-03-17 
15:03:22.000000000 -0800
@@ -548,6 +548,11 @@
     }
 
     vbd_info = kmalloc(MAX_VBDS * sizeof(vdisk_t), GFP_KERNEL);
+    if (unlikely(vbd_info == NULL)) {
+       printk("KERN_ALERT Failed to allocate memory for disk info\n");
+       nr_vbds = 0;
+       return 0;       
+    }
     nr_vbds  = xlvbd_get_vbd_info(vbd_info);
 
     if (nr_vbds < 0) {