[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2] x86/xen: Add some null pointer checking to smp.c
- To: Markus Elfring <Markus.Elfring@xxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, kernel-janitors@xxxxxxxxxxxxxxx
- From: Kunwu Chan <chentao@xxxxxxxxxx>
- Date: Fri, 19 Jan 2024 17:22:25 +0800
- Cc: LKML <linux-kernel@xxxxxxxxxxxxxxx>, kernel test robot <lkp@xxxxxxxxx>, Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>, Borislav Petkov <bp@xxxxxxxxx>, Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>, "H. Peter Anvin" <hpa@xxxxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, Jürgen Groß <jgross@xxxxxxxx>, Thomas Gleixner <tglx@xxxxxxxxxxxxx>, x86@xxxxxxxxxx
- Delivery-date: Sat, 20 Jan 2024 12:45:24 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 2024/1/17 18:40, Markus Elfring wrote:
kasprintf() returns a pointer to dynamically allocated memory
which can be NULL upon failure. Ensure the allocation was successful
by checking the pointer validity.
…
+++ b/arch/x86/xen/smp.c
@@ -61,10 +61,14 @@ void xen_smp_intr_free(unsigned int cpu)
int xen_smp_intr_init(unsigned int cpu)
{
- int rc;
+ int rc = 0;
I find the indication of a successful function execution sufficient by
the statement “return 0;” at the end.
How do you think about to omit such an extra variable initialisation?
Thanks, it's no need now. I'll remove it in v3.
char *resched_name, *callfunc_name, *debug_name;
resched_name = kasprintf(GFP_KERNEL, "resched%d", cpu);
+ if (!resched_name) {
+ rc = -ENOMEM;
+ goto fail;
+ }
per_cpu(xen_resched_irq, cpu).name = resched_name;
rc = bind_ipi_to_irqhandler(XEN_RESCHEDULE_VECTOR,
cpu,
You propose to apply the same error code in four if branches.
I suggest to avoid the specification of duplicate assignment statements
for this purpose.
How do you think about to use another label like “e_nomem”?
I'll add a new label to simply the code.
Regards,
Markus
--
Thanks,
Kunwu
|