[PATCH] RAID5 NULL Checking Bug Fix

david chan (dmchan@stanford.edu)
Tue, 8 May 2001 19:32:55 -0700 (PDT)


Hi,
In drivers/md/raid5.c, the author does not check to see if alloc_page() returns
NULL. This patch also adds checks that return 1 (following the
error-path convention in the respective function).

Please discard this e-mail if this patch is irrelevant to you. I just
tried to be thorough.

Thank you,
David Chan

---snip----
--- drivers/md/raid5.c.orig Tue May 8 19:17:22 2001
+++ drivers/md/raid5.c Tue May 8 19:20:07 2001
@@ -157,17 +157,21 @@
memset(bh, 0, sizeof (struct buffer_head));
init_waitqueue_head(&bh->b_wait);
page = alloc_page(priority);
+ if (!page)
+ goto nomem_path;
bh->b_data = page_address(page);
- if (!bh->b_data) {
- kfree(bh);
- return 1;
- }
+ if (!bh->b_data)
+ goto nomem_path;
atomic_set(&bh->b_count, 0);
bh->b_page = page;
sh->bh_cache[i] = bh;

}
return 0;
+
+nomem_path:
+ kfree(bh);
+ return 1;
}

static struct buffer_head *raid5_build_block (struct stripe_head *sh, int i);
---snip---

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/