Re: [PATCH v3] x86/xen: Add some null pointer checking to smp.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> kasprintf() returns a pointer to dynamically allocated memory
> which can be NULL upon failure. Ensure the allocation was successful
> by checking the pointer validity.
…
> ---
> Changes in v3:
>     - Remove rc initialization
>     - Simply error paths by adding a new label 'fail_mem'
…

I became curious if you would like to simplify further source code places.


> +++ b/arch/x86/xen/smp.c
> @@ -65,6 +65,8 @@ int xen_smp_intr_init(unsigned int cpu)
>  	char *resched_name, *callfunc_name, *debug_name;
>
>  	resched_name = kasprintf(GFP_KERNEL, "resched%d", cpu);
> +	if (!resched_name)
> +		goto fail_mem;

Would you like to add a blank line after such a statement?


>  	per_cpu(xen_resched_irq, cpu).name = resched_name;
…

Please compare with your subsequent suggestion.

…
> @@ -101,6 +108,9 @@ int xen_smp_intr_init(unsigned int cpu)
>  	}
>
>  	callfunc_name = kasprintf(GFP_KERNEL, "callfuncsingle%d", cpu);
> +	if (!callfunc_name)
> +		goto fail_mem;
> +
>  	per_cpu(xen_callfuncsingle_irq, cpu).name = callfunc_name;
…

Regards,
Markus





[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux