Handle maloc() failure in xen_get_nr_phys_cpus()
Subsystems (2)
PATCH 1/1 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.
kexec/crashdump-xen.c +5 -6
@@ -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
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 5 lines · Simon Horman
Currently
xen_get_nr_phys_cpus()doesn't write toxen_phys_notesif allocation fails, but it doesn't return an error either, leavingxen_phys_noteswide open to be accessed by other functions later.Signed-off-by Simon Horman <[email protected]>
Looks good to me.
Quoted 14 lines
Index:
kexec-tools-unstable/kexec/crashdump-xen.c
===================================================================kexec/crashdump-xen.c +0
-5@@ -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 );
kexec/crashdump-xen.c int xen_get_nr_phys_cpus(void) · line 104
Quoted 10 lines
kexec/crashdump-xen.c +5
-1+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
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 10 lines · Ian Campbell
Quoted 5 lines · Simon Horman
Currently
xen_get_nr_phys_cpus()doesn't write toxen_phys_notesif allocation fails, but it doesn't return an error either, leavingxen_phys_noteswide open to be accessed by other functions later.Signed-off-by Simon Horman <[email protected]>Looks good to me.
Acked-by Ian Campbell <[email protected]>
Thanks, I've applied it now.
Signature · 9 lines
Horms H: http://www.vergenet.net/~horms/ W: http://www.valinux.co.jp/en/ _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec