Commit 180418e2 authored by Hou Wenlong's avatar Hou Wenlong Committed by Paolo Bonzini
Browse files

KVM: debugfs: Return retval of simple_attr_open() if it fails



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: default avatarHou Wenlong <houwenlong.hwl@antgroup.com>
Message-Id: <69d64d93accd1f33691b8a383ae555baee80f943.1665975828.git.houwenlong.hwl@antgroup.com>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 5aa02366
Loading
Loading
Loading
Loading
+6 −7
Original line number Original line Diff line number Diff line
@@ -5409,6 +5409,7 @@ static int kvm_debugfs_open(struct inode *inode, struct file *file,
			   int (*get)(void *, u64 *), int (*set)(void *, u64),
			   int (*get)(void *, u64 *), int (*set)(void *, u64),
			   const char *fmt)
			   const char *fmt)
{
{
	int ret;
	struct kvm_stat_data *stat_data = (struct kvm_stat_data *)
	struct kvm_stat_data *stat_data = (struct kvm_stat_data *)
					  inode->i_private;
					  inode->i_private;


@@ -5420,15 +5421,13 @@ static int kvm_debugfs_open(struct inode *inode, struct file *file,
	if (!kvm_get_kvm_safe(stat_data->kvm))
	if (!kvm_get_kvm_safe(stat_data->kvm))
		return -ENOENT;
		return -ENOENT;


	if (simple_attr_open(inode, file, get,
	ret = simple_attr_open(inode, file, get,
			       kvm_stats_debugfs_mode(stat_data->desc) & 0222
			       kvm_stats_debugfs_mode(stat_data->desc) & 0222
		    ? set : NULL,
			       ? set : NULL, fmt);
		    fmt)) {
	if (ret)
		kvm_put_kvm(stat_data->kvm);
		kvm_put_kvm(stat_data->kvm);
		return -ENOMEM;
	}


	return 0;
	return ret;
}
}


static int kvm_debugfs_release(struct inode *inode, struct file *file)
static int kvm_debugfs_release(struct inode *inode, struct file *file)