From: NeilBrown Date: Mon, 13 May 2013 07:09:55 +0000 (+1000) Subject: Always test return value of posix_memalign. X-Git-Tag: mdadm-3.3-rc1~77 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0cf83229992c42cd1a48a29c1fd5c610934714b3;p=thirdparty%2Fmdadm.git Always test return value of posix_memalign. FORTIFY_SOURCE likes this, and it is good practice. Signed-off-by: NeilBrown --- diff --git a/super1.c b/super1.c index eb812757..92e51f7c 100644 --- a/super1.c +++ b/super1.c @@ -668,7 +668,10 @@ static int examine_badblocks_super1(struct supertype *st, int fd, char *devname) } size = __le32_to_cpu(sb->bblog_size)* 512; - posix_memalign((void**)&bbl, 4096, size); + if (posix_memalign((void**)&bbl, 4096, size) != 0) { + pr_err("%s could not allocate badblocks list\n", __func__); + return 0; + } offset = __le64_to_cpu(sb->super_offset) + (int)__le32_to_cpu(sb->bblog_offset); offset <<= 9;