Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

x86/xen: Add some null pointer checking to smp.c

kasprintf() returns a pointer to dynamically allocated memory
which can be NULL upon failure. Ensure the allocation was successful
by checking the pointer validity.

Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202401161119.iof6BQsf-lkp@intel.com/
Suggested-by: Markus Elfring <Markus.Elfring@web.de>
Reviewed-by: Juergen Gross <jgross@suse.com>
Link: https://lore.kernel.org/r/20240119094948.275390-1-chentao@kylinos.cn
Signed-off-by: Juergen Gross <jgross@suse.com>

authored by

Kunwu Chan and committed by
Juergen Gross
3693bb44 7d8c67dd

+12
+12
arch/x86/xen/smp.c
··· 65 65 char *resched_name, *callfunc_name, *debug_name; 66 66 67 67 resched_name = kasprintf(GFP_KERNEL, "resched%d", cpu); 68 + if (!resched_name) 69 + goto fail_mem; 68 70 per_cpu(xen_resched_irq, cpu).name = resched_name; 69 71 rc = bind_ipi_to_irqhandler(XEN_RESCHEDULE_VECTOR, 70 72 cpu, ··· 79 77 per_cpu(xen_resched_irq, cpu).irq = rc; 80 78 81 79 callfunc_name = kasprintf(GFP_KERNEL, "callfunc%d", cpu); 80 + if (!callfunc_name) 81 + goto fail_mem; 82 82 per_cpu(xen_callfunc_irq, cpu).name = callfunc_name; 83 83 rc = bind_ipi_to_irqhandler(XEN_CALL_FUNCTION_VECTOR, 84 84 cpu, ··· 94 90 95 91 if (!xen_fifo_events) { 96 92 debug_name = kasprintf(GFP_KERNEL, "debug%d", cpu); 93 + if (!debug_name) 94 + goto fail_mem; 95 + 97 96 per_cpu(xen_debug_irq, cpu).name = debug_name; 98 97 rc = bind_virq_to_irqhandler(VIRQ_DEBUG, cpu, 99 98 xen_debug_interrupt, ··· 108 101 } 109 102 110 103 callfunc_name = kasprintf(GFP_KERNEL, "callfuncsingle%d", cpu); 104 + if (!callfunc_name) 105 + goto fail_mem; 106 + 111 107 per_cpu(xen_callfuncsingle_irq, cpu).name = callfunc_name; 112 108 rc = bind_ipi_to_irqhandler(XEN_CALL_FUNCTION_SINGLE_VECTOR, 113 109 cpu, ··· 124 114 125 115 return 0; 126 116 117 + fail_mem: 118 + rc = -ENOMEM; 127 119 fail: 128 120 xen_smp_intr_free(cpu); 129 121 return rc;