From: Xiantao Zhang <[EMAIL PROTECTED]>
Date: Mon, 25 Feb 2008 17:11:43 +0800
Subject: [PATCH] kvm: Using kzalloc to avoid allocating kvm_regs from
kernel stack.

Since the size of struct kvm_regs maybe too big to allocate from kernel
stack,
here use kzalloc to allocate it.
Signed-off-by: Xiantao Zhang <[EMAIL PROTECTED]>
---
 virt/kvm/kvm_main.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index cf6df51..5348538 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -806,25 +806,26 @@ static long kvm_vcpu_ioctl(struct file *filp,
                r = kvm_arch_vcpu_ioctl_run(vcpu, vcpu->run);
                break;
        case KVM_GET_REGS: {
-               struct kvm_regs kvm_regs;
+               struct kvm_regs *kvm_regs;
 
-               memset(&kvm_regs, 0, sizeof kvm_regs);
-               r = kvm_arch_vcpu_ioctl_get_regs(vcpu, &kvm_regs);
+               kvm_regs = kzalloc(sizeof(struct kvm_regs), GFP_KERNEL);
+               r = kvm_arch_vcpu_ioctl_get_regs(vcpu, kvm_regs);
                if (r)
                        goto out;
                r = -EFAULT;
-               if (copy_to_user(argp, &kvm_regs, sizeof kvm_regs))
+               if (copy_to_user(argp, kvm_regs, sizeof(struct
kvm_regs)))
                        goto out;
                r = 0;
                break;
        }
        case KVM_SET_REGS: {
-               struct kvm_regs kvm_regs;
+               struct kvm_regs *kvm_regs;
 
+               kvm_regs = kzalloc(sizeof(struct kvm_regs), GFP_KERNEL);
                r = -EFAULT;
-               if (copy_from_user(&kvm_regs, argp, sizeof kvm_regs))
+               if (copy_from_user(kvm_regs, argp, sizeof(struct
kvm_regs)))
                        goto out;
-               r = kvm_arch_vcpu_ioctl_set_regs(vcpu, &kvm_regs);
+               r = kvm_arch_vcpu_ioctl_set_regs(vcpu, kvm_regs);
                if (r)
                        goto out;
                r = 0;
-- 
1.5.2

Attachment: 0001-kvm-Using-kzalloc-to-avoid-allocating-kvm_regs-from.patch
Description: 0001-kvm-Using-kzalloc-to-avoid-allocating-kvm_regs-from.patch

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel

Reply via email to