From mboxrd@z Thu Jan 1 00:00:00 1970 From: walimis Subject: Re: [PATCH 2/3] kvm tools: check negative value of num_pages Date: Thu, 11 Aug 2011 21:37:34 +0800 Message-ID: <20110811133734.GF13190@walimis-desktop> References: <1313047370.3456.3.camel@lappy> <1313047319-20293-1-git-send-email-walimisdev@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Sasha Levin , Ingo Molnar , Asias He , kvm@vger.kernel.org To: Pekka Enberg Return-path: Received: from mail-wy0-f174.google.com ([74.125.82.174]:57902 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751033Ab1HKNxi (ORCPT ); Thu, 11 Aug 2011 09:53:38 -0400 Received: by wyg24 with SMTP id 24so1432825wyg.19 for ; Thu, 11 Aug 2011 06:53:37 -0700 (PDT) Content-Disposition: inline In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: On Thu, Aug 11, 2011 at 04:36:29PM +0300, Pekka Enberg wrote: >On Thu, 11 Aug 2011, Liming Wang wrote: >>If num_pages is negative, balloon will make kernel crash with >>"out of memory". So we check this value to avoid it to be negative. >> >>Signed-off-by: Liming Wang >>--- >>tools/kvm/virtio/balloon.c | 8 ++++++-- >>1 files changed, 6 insertions(+), 2 deletions(-) >> >>diff --git a/tools/kvm/virtio/balloon.c b/tools/kvm/virtio/balloon.c >>index 854d04b..941023e 100644 >>--- a/tools/kvm/virtio/balloon.c >>+++ b/tools/kvm/virtio/balloon.c >>@@ -220,10 +220,14 @@ static struct ioport_operations virtio_bln_io_ops = { >> >>static void handle_sigmem(int sig) >>{ >>- if (sig == SIGKVMADDMEM) >>+ if (sig == SIGKVMADDMEM) { >> bdev.config.num_pages += 256; >>- else >>+ } else { >>+ if (bdev.config.num_pages < 256){ > >Space missing before opening brace. > >>+ return; >>+ } > >Please don't use braces for single line if statements. > >I'll fix it up myself. You can use the scripts/checkpatch script to >check for this kind of trivial coding style issues before sending a >patch out. OK, I will take note next time. walimis > >> bdev.config.num_pages -= 256; >>+ } >> >> /* Notify that the configuration space has changed */ >> bdev.isr = VIRTIO_PCI_ISR_CONFIG; >>-- >>1.7.0.4 >> >>