Skip to contentSkip to conversation

swsusp: fix return value when alloc fail

PATCH In review Stanislaw Gruszka 2 participants 2 messages Feb 12, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 swsusp: fix return value when alloc fail

Currently we return 0 in swsusp_alloc() when alloc_image_page() fail. Patch fixes that. Also remove unneeded "error" variable since only possible error is -ENOMEM.

---
 kernel/power/snapshot.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)
kernel/power/snapshot.c +2 -5
index 0dac75e..64db648 100644
@@ -1519,11 +1519,8 @@ static int
 swsusp_alloc(struct memory_bitmap *orig_bm, struct memory_bitmap *copy_bm,
 		unsigned int nr_pages, unsigned int nr_highmem)
 {
-	int error = 0;
-
 	if (nr_highmem > 0) {
-		error = get_highmem_buffer(PG_ANY);
-		if (error)
+		if (get_highmem_buffer(PG_ANY))
 			goto err_out;
 		if (nr_highmem > alloc_highmem) {
 			nr_highmem -= alloc_highmem;
@@ -1546,7 +1543,7 @@ swsusp_alloc(struct memory_bitmap *orig_bm, struct memory_bitmap *copy_bm,
 
  err_out:
 	swsusp_free();
-	return error;
+	return -ENOMEM;
 }
 
 asmlinkage int swsusp_save(void)
Signature · 1 line
1.7.4
#1 lore raw
Quoted 5 lines · Stanislaw Gruszka

Currently we return 0 in swsusp_alloc() when alloc_image_page() fail. Patch fixes that. Also remove unneeded "error" variable since only possible error is -ENOMEM.

Good catch, thanks! Patch applied to suspend-2.6/linux-next.

Rafael

Quoted 31 lines
---
 kernel/power/snapshot.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)
kernel/power/snapshot.c +2 -5
index 0dac75e..64db648 100644
@@ -1519,11 +1519,8 @@ static int
 swsusp_alloc(struct memory_bitmap *orig_bm, struct memory_bitmap *copy_bm,
 		unsigned int nr_pages, unsigned int nr_highmem)
 {
-	int error = 0;
-
 	if (nr_highmem > 0) {
-		error = get_highmem_buffer(PG_ANY);
-		if (error)
+		if (get_highmem_buffer(PG_ANY))
 			goto err_out;
 		if (nr_highmem > alloc_highmem) {
 			nr_highmem -= alloc_highmem;
@@ -1546,7 +1543,7 @@ swsusp_alloc(struct memory_bitmap *orig_bm, struct memory_bitmap *copy_bm,
 
  err_out:
 	swsusp_free();
-	return error;
+	return -ENOMEM;
 }
 
 asmlinkage int swsusp_save(void)