diff options
author | Simon Horman <horms@verge.net.au> | 2007-05-09 18:56:09 +0900 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2007-05-10 10:28:39 +0900 |
commit | f7129ad11f75ef27416784c39c29b0e8906d8844 (patch) | |
tree | 3cc6c6f862bf40281ebd3d415ed168538e3b9e5b | |
parent | c58ed3b1b4f538bbd784ee3087e4d5e467637fcf (diff) |
Handle maloc() failure in xen_get_nr_phys_cpus()
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.
Acked-by: Ian Campbell <ian.campbell@xensource.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
-rw-r--r-- | kexec/crashdump-xen.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/kexec/crashdump-xen.c b/kexec/crashdump-xen.c index 30506e2..fcef9db 100644 --- a/kexec/crashdump-xen.c +++ b/kexec/crashdump-xen.c @@ -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; } |