From: Vitaly Kuznetsov Date: Tue, 31 Mar 2015 18:16:40 +0000 (-0700) Subject: Drivers: hv: hv_balloon: correctly handle val.freeram Signed-off-by: Vitaly Kuznetsov Reviewed-by: Laszlo Ersek Signed-off-by: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c index 74312c88534a..4052ad8255fa 100644 --- a/drivers/hv/hv_balloon.c +++ b/drivers/hv/hv_balloon.c @@ -1155,7 +1155,7 @@ static void balloon_up(struct work_struct *dummy) floor = compute_balloon_floor(); /* Refuse to balloon below the floor, keep the 2M granularity. */ - if (val.freeram - num_pages < floor) { + if (val.freeram < num_pages || val.freeram - num_pages < floor) { num_pages = val.freeram > floor ? (val.freeram - floor) : 0; num_pages -= num_pages % PAGES_IN_2M; }