From: Michael Ellerman <mpe@ellerman.id.au>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
Paul Mackerras <paulus@ozlabs.org>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
kvm-ppc@vger.kernel.org
Subject: Re: [PATCH 2/6] powerpc: kvm: no need to check return value of debugfs_create functions
Date: Tue, 03 Mar 2020 10:32:19 +0000 [thread overview]
Message-ID: <874kv5sp8s.fsf@mpe.ellerman.id.au> (raw)
In-Reply-To: <20200303095849.GA1399072@kroah.com>
Greg Kroah-Hartman <gregkh@linuxfoundation.org> writes:
> On Tue, Mar 03, 2020 at 08:45:23PM +1100, Michael Ellerman wrote:
>> Greg Kroah-Hartman <gregkh@linuxfoundation.org> writes:
>> > On Tue, Mar 03, 2020 at 06:46:23PM +1100, Michael Ellerman wrote:
>> >> Greg Kroah-Hartman <gregkh@linuxfoundation.org> writes:
>> >> > When calling debugfs functions, there is no need to ever check the
>> >> > return value. The function can work or not, but the code logic should
>> >> > never do something different based on this.
>> >>
>> >> Except it does need to do something different, if the file was created
>> >> it needs to be removed in the remove path.
>> >>
>> >> > diff --git a/arch/powerpc/kvm/timing.c b/arch/powerpc/kvm/timing.c
>> >> > index bfe4f106cffc..8e4791c6f2af 100644
>> >> > --- a/arch/powerpc/kvm/timing.c
>> >> > +++ b/arch/powerpc/kvm/timing.c
>> >> > @@ -207,19 +207,12 @@ static const struct file_operations kvmppc_exit_timing_fops = {
>> >> > void kvmppc_create_vcpu_debugfs(struct kvm_vcpu *vcpu, unsigned int id)
>> >> > {
>> >> > static char dbg_fname[50];
>> >> > - struct dentry *debugfs_file;
>> >> >
>> >> > snprintf(dbg_fname, sizeof(dbg_fname), "vm%u_vcpu%u_timing",
>> >> > current->pid, id);
>> >> > - debugfs_file = debugfs_create_file(dbg_fname, 0666,
>> >> > - kvm_debugfs_dir, vcpu,
>> >> > - &kvmppc_exit_timing_fops);
>> >> > -
>> >> > - if (!debugfs_file) {
>> >> > - printk(KERN_ERR"%s: error creating debugfs file %s\n",
>> >> > - __func__, dbg_fname);
>> >> > - return;
>> >> > - }
>> >> > + debugfs_create_file(dbg_fname, 0666, kvm_debugfs_dir, vcpu,
>> >> > + &kvmppc_exit_timing_fops);
>> >> > +
>> >> >
>> >> > vcpu->arch.debugfs_exit_timing = debugfs_file;
>> >
>> > Ugh, you are right, how did I miss that? How is 0-day missing this?
>> > It's been in my tree for a long time, odd.
>>
>> This code isn't enabled by default, or in any defconfig. So it's only
>> allmodconfig that would trip it, I guess 0-day isn't doing powerpc
>> allmodconfig builds.
>>
>> >> I squashed this in, which seems to work:
>> ...
>> >>
>> >> void kvmppc_remove_vcpu_debugfs(struct kvm_vcpu *vcpu)
>> >> {
>> >> - if (vcpu->arch.debugfs_exit_timing) {
>> >> + if (!IS_ERR_OR_NULL(vcpu->arch.debugfs_exit_timing)) {
>> >> debugfs_remove(vcpu->arch.debugfs_exit_timing);
>> >> vcpu->arch.debugfs_exit_timing = NULL;
>> >> }
>> >
>> > No, this can just be:
>> > debugfs_remove(vcpu->arch.debugfs_exit_timing);
>> >
>> > No need to check anything, just call it and the debugfs code can handle
>> > it just fine.
>>
>> Oh duh, of course, I should have checked.
>>
>> I'd still like to NULL out the debugfs_exit_timing member, so I'll do:
>>
>> void kvmppc_remove_vcpu_debugfs(struct kvm_vcpu *vcpu)
>> {
>> debugfs_remove(vcpu->arch.debugfs_exit_timing);
>> vcpu->arch.debugfs_exit_timing = NULL;
>> }
>
> Fair enough, but I doubt it ever matters :)
Yeah, but I'm paranoid and I have no way to test this code :)
> Thanks for the fixups, sorry for sending a broken patch, my fault.
No worries, we have too many CONFIG options.
cheers
WARNING: multiple messages have this Message-ID (diff)
From: Michael Ellerman <mpe@ellerman.id.au>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
kvm-ppc@vger.kernel.org
Subject: Re: [PATCH 2/6] powerpc: kvm: no need to check return value of debugfs_create functions
Date: Tue, 03 Mar 2020 21:32:19 +1100 [thread overview]
Message-ID: <874kv5sp8s.fsf@mpe.ellerman.id.au> (raw)
In-Reply-To: <20200303095849.GA1399072@kroah.com>
Greg Kroah-Hartman <gregkh@linuxfoundation.org> writes:
> On Tue, Mar 03, 2020 at 08:45:23PM +1100, Michael Ellerman wrote:
>> Greg Kroah-Hartman <gregkh@linuxfoundation.org> writes:
>> > On Tue, Mar 03, 2020 at 06:46:23PM +1100, Michael Ellerman wrote:
>> >> Greg Kroah-Hartman <gregkh@linuxfoundation.org> writes:
>> >> > When calling debugfs functions, there is no need to ever check the
>> >> > return value. The function can work or not, but the code logic should
>> >> > never do something different based on this.
>> >>
>> >> Except it does need to do something different, if the file was created
>> >> it needs to be removed in the remove path.
>> >>
>> >> > diff --git a/arch/powerpc/kvm/timing.c b/arch/powerpc/kvm/timing.c
>> >> > index bfe4f106cffc..8e4791c6f2af 100644
>> >> > --- a/arch/powerpc/kvm/timing.c
>> >> > +++ b/arch/powerpc/kvm/timing.c
>> >> > @@ -207,19 +207,12 @@ static const struct file_operations kvmppc_exit_timing_fops = {
>> >> > void kvmppc_create_vcpu_debugfs(struct kvm_vcpu *vcpu, unsigned int id)
>> >> > {
>> >> > static char dbg_fname[50];
>> >> > - struct dentry *debugfs_file;
>> >> >
>> >> > snprintf(dbg_fname, sizeof(dbg_fname), "vm%u_vcpu%u_timing",
>> >> > current->pid, id);
>> >> > - debugfs_file = debugfs_create_file(dbg_fname, 0666,
>> >> > - kvm_debugfs_dir, vcpu,
>> >> > - &kvmppc_exit_timing_fops);
>> >> > -
>> >> > - if (!debugfs_file) {
>> >> > - printk(KERN_ERR"%s: error creating debugfs file %s\n",
>> >> > - __func__, dbg_fname);
>> >> > - return;
>> >> > - }
>> >> > + debugfs_create_file(dbg_fname, 0666, kvm_debugfs_dir, vcpu,
>> >> > + &kvmppc_exit_timing_fops);
>> >> > +
>> >> >
>> >> > vcpu->arch.debugfs_exit_timing = debugfs_file;
>> >
>> > Ugh, you are right, how did I miss that? How is 0-day missing this?
>> > It's been in my tree for a long time, odd.
>>
>> This code isn't enabled by default, or in any defconfig. So it's only
>> allmodconfig that would trip it, I guess 0-day isn't doing powerpc
>> allmodconfig builds.
>>
>> >> I squashed this in, which seems to work:
>> ...
>> >>
>> >> void kvmppc_remove_vcpu_debugfs(struct kvm_vcpu *vcpu)
>> >> {
>> >> - if (vcpu->arch.debugfs_exit_timing) {
>> >> + if (!IS_ERR_OR_NULL(vcpu->arch.debugfs_exit_timing)) {
>> >> debugfs_remove(vcpu->arch.debugfs_exit_timing);
>> >> vcpu->arch.debugfs_exit_timing = NULL;
>> >> }
>> >
>> > No, this can just be:
>> > debugfs_remove(vcpu->arch.debugfs_exit_timing);
>> >
>> > No need to check anything, just call it and the debugfs code can handle
>> > it just fine.
>>
>> Oh duh, of course, I should have checked.
>>
>> I'd still like to NULL out the debugfs_exit_timing member, so I'll do:
>>
>> void kvmppc_remove_vcpu_debugfs(struct kvm_vcpu *vcpu)
>> {
>> debugfs_remove(vcpu->arch.debugfs_exit_timing);
>> vcpu->arch.debugfs_exit_timing = NULL;
>> }
>
> Fair enough, but I doubt it ever matters :)
Yeah, but I'm paranoid and I have no way to test this code :)
> Thanks for the fixups, sorry for sending a broken patch, my fault.
No worries, we have too many CONFIG options.
cheers
next prev parent reply other threads:[~2020-03-03 10:32 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-09 10:58 [PATCH 1/6] powerpc: kernel: no need to check return value of debugfs_create functions Greg Kroah-Hartman
2020-02-09 10:58 ` [PATCH 2/6] powerpc: kvm: " Greg Kroah-Hartman
2020-02-09 10:58 ` Greg Kroah-Hartman
2020-03-03 7:46 ` Michael Ellerman
2020-03-03 7:46 ` Michael Ellerman
2020-03-03 8:50 ` Greg Kroah-Hartman
2020-03-03 8:50 ` Greg Kroah-Hartman
2020-03-03 9:45 ` Michael Ellerman
2020-03-03 9:45 ` Michael Ellerman
2020-03-03 9:58 ` Greg Kroah-Hartman
2020-03-03 9:58 ` Greg Kroah-Hartman
2020-03-03 10:32 ` Michael Ellerman [this message]
2020-03-03 10:32 ` Michael Ellerman
2020-02-09 10:58 ` [PATCH 3/6] powerpc: mm: book3s64: hash_utils: " Greg Kroah-Hartman
2020-02-09 10:58 ` [PATCH 4/6] powerpc: mm: ptdump: " Greg Kroah-Hartman
2020-02-09 10:59 ` [PATCH 5/6] powerpc: cell: axon_msi: " Greg Kroah-Hartman
2020-02-09 10:59 ` [PATCH 6/6] powerpc: powernv: " Greg Kroah-Hartman
2020-02-10 15:01 ` Oliver O'Halloran
2020-02-10 15:19 ` Greg Kroah-Hartman
2020-03-03 9:52 ` Michael Ellerman
2020-03-06 0:27 ` [PATCH 1/6] powerpc: kernel: " Michael Ellerman
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=874kv5sp8s.fsf@mpe.ellerman.id.au \
--to=mpe@ellerman.id.au \
--cc=benh@kernel.crashing.org \
--cc=gregkh@linuxfoundation.org \
--cc=kvm-ppc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=paulus@ozlabs.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.