From: Dan Carpenter <dan.carpenter@linaro.org>
To: Kunwu Chan <chentao@kylinos.cn>
Cc: "Markus Elfring" <Markus.Elfring@web.de>,
xen-devel@lists.xenproject.org, kernel-janitors@vger.kernel.org,
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: Mon, 22 Jan 2024 11:30:02 +0300 [thread overview]
Message-ID: <dfb6de51-3ebc-41fc-a750-cf5ca2ac05aa@moroto.mountain> (raw)
In-Reply-To: <517fae75-c4e7-4576-81ff-6a14a3eb9cd7@kylinos.cn>
On Fri, Jan 19, 2024 at 05:22:25PM +0800, Kunwu Chan wrote:
> 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.
This advice is good. Don't do unnecessary assignments.
> >
> >
> > > 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.
I'm not a Xen maintainer so I can't really comment on their style
choices. However, as one of the kernel-janitors list people, I would
say that not everyone agrees with Markus's style preferences. Markus
was banned from the list for a while, but we unbanned everyone when we
transitioned to the new list infrastructure. Do a search on lore to
find out more. https://lore.kernel.org/all/?q=Elfring
Perhaps wait for feedback from the maintainers for how to proceed?
regards,
dan carpenter
next prev parent reply other threads:[~2024-01-22 8:30 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
2024-01-22 8:30 ` Dan Carpenter [this message]
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=dfb6de51-3ebc-41fc-a750-cf5ca2ac05aa@moroto.mountain \
--to=dan.carpenter@linaro.org \
--cc=Markus.Elfring@web.de \
--cc=boris.ostrovsky@oracle.com \
--cc=bp@alien8.de \
--cc=chentao@kylinos.cn \
--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®