mirror of
https://github.com/clearlinux/kvmtool.git
synced 2026-09-06 21:51:49 +00:00
kvm tools: check negative value of num_pages
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 <walimisdev@gmail.com> [ penberg@kernel.org: cleanups ] Signed-off-by: Pekka Enberg <penberg@kernel.org>
This commit is contained in:
+6
-2
@@ -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)
|
||||
return;
|
||||
|
||||
bdev.config.num_pages -= 256;
|
||||
}
|
||||
|
||||
/* Notify that the configuration space has changed */
|
||||
bdev.isr = VIRTIO_PCI_ISR_CONFIG;
|
||||
|
||||
Reference in New Issue
Block a user