From: Paolo Bonzini <pbonzini@redhat.com>
To: Hou Wenlong <houwenlong.hwl@antgroup.com>, kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] KVM: debugfs: Return retval of simple_attr_open() if it fails
Date: Sat, 22 Oct 2022 11:08:58 +0200 [thread overview]
Message-ID: <f9327f38-72b3-bf65-a318-bf5982364c15@redhat.com> (raw)
In-Reply-To: <69d64d93accd1f33691b8a383ae555baee80f943.1665975828.git.houwenlong.hwl@antgroup.com>
On 10/17/22 05:06, Hou Wenlong wrote:
> Although simple_attr_open() fails only with -ENOMEM with current code
> base, it would be nicer to return retval of simple_attr_open() directly
> in kvm_debugfs_open().
>
> No functional change intended.
>
> Signed-off-by: Hou Wenlong <houwenlong.hwl@antgroup.com>
> ---
> virt/kvm/kvm_main.c | 13 ++++++-------
> 1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index e30f1b4ecfa5..f7b06c1e8827 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -5398,6 +5398,7 @@ static int kvm_debugfs_open(struct inode *inode, struct file *file,
> int (*get)(void *, u64 *), int (*set)(void *, u64),
> const char *fmt)
> {
> + int ret;
> struct kvm_stat_data *stat_data = (struct kvm_stat_data *)
> inode->i_private;
>
> @@ -5409,15 +5410,13 @@ static int kvm_debugfs_open(struct inode *inode, struct file *file,
> if (!kvm_get_kvm_safe(stat_data->kvm))
> return -ENOENT;
>
> - if (simple_attr_open(inode, file, get,
> - kvm_stats_debugfs_mode(stat_data->desc) & 0222
> - ? set : NULL,
> - fmt)) {
> + ret = simple_attr_open(inode, file, get,
> + kvm_stats_debugfs_mode(stat_data->desc) & 0222
> + ? set : NULL, fmt);
> + if (ret)
> kvm_put_kvm(stat_data->kvm);
> - return -ENOMEM;
> - }
>
> - return 0;
> + return ret;
> }
>
> static int kvm_debugfs_release(struct inode *inode, struct file *file)
Queued, thanks.
Paolo
next prev parent reply other threads:[~2022-10-22 11:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-17 3:06 [PATCH v2 1/2] KVM: x86: Reduce refcount if single_open() fails in kvm_mmu_rmaps_stat_open() Hou Wenlong
2022-10-17 3:06 ` [PATCH v2 2/2] KVM: debugfs: Return retval of simple_attr_open() if it fails Hou Wenlong
2022-10-22 9:08 ` Paolo Bonzini [this message]
2022-10-17 18:05 ` [PATCH v2 1/2] KVM: x86: Reduce refcount if single_open() fails in kvm_mmu_rmaps_stat_open() Peter Xu
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=f9327f38-72b3-bf65-a318-bf5982364c15@redhat.com \
--to=pbonzini@redhat.com \
--cc=houwenlong.hwl@antgroup.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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®