From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nivedita Singhvi Subject: [Patch xen-unstable] mem alloc handling in xlvbd_init() Date: Thu, 17 Mar 2005 15:53:38 -0800 Message-ID: <423A1882.30908@us.ibm.com> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------060004040102040105080006" In-Reply-To: Sender: xen-devel-admin@lists.sourceforge.net Errors-To: xen-devel-admin@lists.sourceforge.net List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , List-Archive: To: xen-devel@lists.sourceforge.net List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------060004040102040105080006 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 --------------060004040102040105080006 Content-Type: text/plain; name="p1.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="p1.patch" 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) { --------------060004040102040105080006-- ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click