public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hv: hv_balloon: avoid memory leak on alloc_error of 2MB memory block
@ 2014-11-24  5:56 Dexuan Cui
  2014-11-24  5:18 ` Jason Wang
  0 siblings, 1 reply; 8+ messages in thread
From: Dexuan Cui @ 2014-11-24  5:56 UTC (permalink / raw)
  To: gregkh, linux-kernel, driverdev-devel, olaf, apw, jasowang, kys; +Cc: haiyangz

If num_ballooned is not 0, we shouldn't neglect the already-allocated 2MB
memory block(s).

Cc: K. Y. Srinivasan <kys@microsoft.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Dexuan Cui <decui@microsoft.com>
---
 drivers/hv/hv_balloon.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
index 5e90c5d..cba2d3b 100644
--- a/drivers/hv/hv_balloon.c
+++ b/drivers/hv/hv_balloon.c
@@ -1091,6 +1091,8 @@ static void balloon_up(struct work_struct *dummy)
 	bool done = false;
 	int i;
 
+	/* The host does balloon_up in 2MB. */
+	WARN_ON(num_pages % PAGES_IN_2M != 0);
 
 	/*
 	 * We will attempt 2M allocations. However, if we fail to
@@ -1111,7 +1113,7 @@ static void balloon_up(struct work_struct *dummy)
 						bl_resp, alloc_unit,
 						 &alloc_error);
 
-		if ((alloc_error) && (alloc_unit != 1)) {
+		if (alloc_error && (alloc_unit != 1) && num_ballooned == 0) {
 			alloc_unit = 1;
 			continue;
 		}
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-11-24 21:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-24  5:56 [PATCH] hv: hv_balloon: avoid memory leak on alloc_error of 2MB memory block Dexuan Cui
2014-11-24  5:18 ` Jason Wang
2014-11-24  6:08   ` Dexuan Cui
2014-11-24  7:28     ` Jason Wang
2014-11-24  7:54       ` Dexuan Cui
2014-11-24  8:47         ` Jason Wang
2014-11-24  8:55           ` Dexuan Cui
2014-11-24 21:55             ` KY Srinivasan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox