From: Hollis Blanchard <hollisb@us.ibm.com>
To: "Zhang, Xiantao" <xiantao.zhang@intel.com>
Cc: kvm-devel@lists.sourceforge.net,
kvm-ia64-devel@lists.sourceforge.net,
Avi Kivity <avi@qumranet.com>
Subject: Re: [PATCH] Using kzalloc to avoid allocating kvm_regs from kernel stack
Date: Mon, 25 Feb 2008 10:38:05 -0600 [thread overview]
Message-ID: <1203957485.18635.1.camel@basalt> (raw)
In-Reply-To: <42DFA526FC41B1429CE7279EF83C6BDCE38A4F@pdsmsx415.ccr.corp.intel.com>
On Mon, 2008-02-25 at 17:34 +0800, Zhang, Xiantao wrote:
> From: Xiantao Zhang <xiantao.zhang@intel.com>
> 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 <xiantao.zhang@intel.com>
> ---
> 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;
Where is this freed?
--
Hollis Blanchard
IBM Linux Technology Center
-------------------------------------------------------------------------
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/
next prev parent reply other threads:[~2008-02-25 16:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-25 9:34 [PATCH] Using kzalloc to avoid allocating kvm_regs from kernel stack Zhang, Xiantao
2008-02-25 16:38 ` Hollis Blanchard [this message]
2008-02-25 16:39 ` Hollis Blanchard
-- strict thread matches above, loose matches on Subject: below --
2008-02-25 9:43 Zhang, Xiantao
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=1203957485.18635.1.camel@basalt \
--to=hollisb@us.ibm.com \
--cc=avi@qumranet.com \
--cc=kvm-devel@lists.sourceforge.net \
--cc=kvm-ia64-devel@lists.sourceforge.net \
--cc=xiantao.zhang@intel.com \
/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