Return-path: Received: from koto.vergenet.net ([210.128.90.7]) by canuck.infradead.org with esmtp (Exim 4.63 #1 (Red Hat Linux)) id 1Hliu9-0001k2-BT for kexec@lists.infradead.org; Wed, 09 May 2007 05:56:18 -0400 From: Simon Horman Subject: [PATCH] Handle maloc() failure in xen_get_nr_phys_cpus() Message-Id: <20070509095609.44BAA4F7D7@tabatha.lab.ultramonkey.org> Date: Wed, 9 May 2007 18:56:09 +0900 (JST) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: kexec-bounces@lists.infradead.org Errors-To: kexec-bounces+dwmw2=infradead.org+dwmw2=infradead.org@lists.infradead.org To: kexec@lists.infradead.org Cc: Ian Campbell Currently xen_get_nr_phys_cpus() doesn't write to xen_phys_notes if allocation fails, but it doesn't return an error either, leaving xen_phys_notes wide open to be accessed by other functions later. Signed-off-by: Simon Horman Index: kexec-tools-unstable/kexec/crashdump-xen.c =================================================================== --- kexec-tools-unstable.orig/kexec/crashdump-xen.c 2007-05-09 18:44:48.000000000 +0900 +++ kexec-tools-unstable/kexec/crashdump-xen.c 2007-05-09 18:50:14.000000000 +0900 @@ -93,13 +93,12 @@ int xen_get_nr_phys_cpus(void) if ((cpus = kexec_iomem_for_each_line(match, NULL, NULL))) { n = sizeof(struct crash_note_info) * cpus; xen_phys_notes = malloc(n); - if (xen_phys_notes) { - memset(xen_phys_notes, 0, n); - kexec_iomem_for_each_line(match, - xen_crash_note_callback, - NULL); + if (!xen_phys_notes) { + fprintf(stderr, "failed to allocate xen_phys_notes.\n"); + return -1; } - + memset(xen_phys_notes, 0, n); + kexec_iomem_for_each_line(match, xen_crash_note_callback, NULL); xen_phys_cpus = cpus; } _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec