mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kunwu Chan <chentao@kylinos.cn>
To: Markus Elfring <Markus.Elfring@web.de>,
	xen-devel@lists.xenproject.org, kernel-janitors@vger.kernel.org
Cc: LKML <linux-kernel@vger.kernel.org>,
	"kernel test robot" <lkp@intel.com>,
	"Boris Ostrovsky" <boris.ostrovsky@oracle.com>,
	"Borislav Petkov" <bp@alien8.de>,
	"Dave Hansen" <dave.hansen@linux.intel.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	"Ingo Molnar" <mingo@redhat.com>, "Jürgen Groß" <jgross@suse.com>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	x86@kernel.org
Subject: Re: [PATCH v2] x86/xen: Add some null pointer checking to smp.c
Date: Fri, 19 Jan 2024 17:22:25 +0800	[thread overview]
Message-ID: <517fae75-c4e7-4576-81ff-6a14a3eb9cd7@kylinos.cn> (raw)
In-Reply-To: <1705655941162581.825.seg@mailgw>

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


  parent reply	other threads:[~2024-01-19  9:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-17  9:00 Kunwu Chan
2024-01-17 10:40 ` Markus Elfring
     [not found] ` <1705655941162581.825.seg@mailgw>
2024-01-19  9:22   ` Kunwu Chan [this message]
2024-01-22  8:30     ` Dan Carpenter
2024-01-22  8:41       ` Kunwu Chan
2024-01-22 10:06       ` [v2] " Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=517fae75-c4e7-4576-81ff-6a14a3eb9cd7@kylinos.cn \
    --to=chentao@kylinos.cn \
    --cc=Markus.Elfring@web.de \
    --cc=boris.ostrovsky@oracle.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jgross@suse.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®