Skip to contentSkip to conversation

KVM: return the error code from kvm_arch_create_vm_debugfs when it fails

PATCH In review [email protected] 2 participants 2 messages Dec 23, 2021 – Dec 25, 2021 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: return the error code from kvm_arch_create_vm_debugfs when it fails

From: Chen Gang <[email protected]>

At present, kvm_arch_create_vm_debugfs is a new interface for arch, and it assumes return an none-zero error code, so the caller need check it and return it to the user mode.

---
 virt/kvm/kvm_main.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
virt/kvm/kvm_main.c +5 -4
index d8a1a17bcb7e..b2de428bd4c7 100644
@@ -1015,7 +1015,7 @@ static int kvm_create_vm_debugfs(struct kvm *kvm, int fd)
 	ret = kvm_arch_create_vm_debugfs(kvm);
 	if (ret) {
 		kvm_destroy_vm_debugfs(kvm);
-		return i;
+		return ret;
 	}
 
 	return 0;
@@ -4727,7 +4727,7 @@ EXPORT_SYMBOL_GPL(file_is_kvm);
 
 static int kvm_dev_ioctl_create_vm(unsigned long type)
 {
-	int r;
+	int r, ret;
 	struct kvm *kvm;
 	struct file *file;
 
@@ -4759,10 +4759,11 @@ static int kvm_dev_ioctl_create_vm(unsigned long type)
 	 * cases it will be called by the final fput(file) and will take
 	 * care of doing kvm_put_kvm(kvm).
 	 */
-	if (kvm_create_vm_debugfs(kvm, r) < 0) {
+	ret = kvm_create_vm_debugfs(kvm, r);
+	if (ret) {
 		put_unused_fd(r);
 		fput(file);
-		return -ENOMEM;
+		return ret;
 	}
 	kvm_uevent_notify_change(KVM_EVENT_CREATE_VM, kvm);
 
Signature · 1 line
2.24.0.308.g228f53135a
#1 lore raw

Hello:

The original mail was not sent successfully, so I send it again with another mailbox.

Thanks.

Quoted 48 lines · On 12/23/21 9:34 AM, [email protected] wrote:

From: Chen Gang <[email protected]>

At present, kvm_arch_create_vm_debugfs is a new interface for arch, and it assumes return an none-zero error code, so the caller need check it and return it to the user mode.

---
 virt/kvm/kvm_main.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
virt/kvm/kvm_main.c +5 -4
index d8a1a17bcb7e..b2de428bd4c7 100644
@@ -1015,7 +1015,7 @@ static int kvm_create_vm_debugfs(struct kvm *kvm, int fd)
 	ret = kvm_arch_create_vm_debugfs(kvm);
 	if (ret) {
 		kvm_destroy_vm_debugfs(kvm);
-		return i;
+		return ret;
 	}
 
 	return 0;
@@ -4727,7 +4727,7 @@ EXPORT_SYMBOL_GPL(file_is_kvm);
 
 static int kvm_dev_ioctl_create_vm(unsigned long type)
 {
-	int r;
+	int r, ret;
 	struct kvm *kvm;
 	struct file *file;
 
@@ -4759,10 +4759,11 @@ static int kvm_dev_ioctl_create_vm(unsigned long type)
 	 * cases it will be called by the final fput(file) and will take
 	 * care of doing kvm_put_kvm(kvm).
 	 */
-	if (kvm_create_vm_debugfs(kvm, r) < 0) {
+	ret = kvm_create_vm_debugfs(kvm, r);
+	if (ret) {
 		put_unused_fd(r);
 		fput(file);
-		return -ENOMEM;
+		return ret;
 	}
 	kvm_uevent_notify_change(KVM_EVENT_CREATE_VM, kvm);