Date: Thu, 2 Apr 2009 17:16:39 +0000 (UTC) From: Xin LI <delphij@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r190646 - head/lib/libufs Message-ID: <200904021716.n32HGdE0070869@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: delphij Date: Thu Apr 2 17:16:39 2009 New Revision: 190646 URL: http://svn.freebsd.org/changeset/base/190646 Log: Bail out when memory allocation is failed, rather than referencing a NULL pointer. PR: kern/94480 Submitted by: Michiel Pelt <m.pelt xs4all nl> Modified: head/lib/libufs/block.c Modified: head/lib/libufs/block.c ============================================================================== --- head/lib/libufs/block.c Thu Apr 2 17:15:49 2009 (r190645) +++ head/lib/libufs/block.c Thu Apr 2 17:16:39 2009 (r190646) @@ -64,8 +64,10 @@ bread(struct uufsd *disk, ufs2_daddr_t b */ if (((intptr_t)data) & 0x3f) { p2 = malloc(size); - if (p2 == NULL) + if (p2 == NULL) { ERROR(disk, "allocate bounce buffer"); + goto fail; + } } cnt = pread(disk->d_fd, p2, size, (off_t)(blockno * disk->d_bsize)); if (cnt == -1) { @@ -115,8 +117,10 @@ bwrite(struct uufsd *disk, ufs2_daddr_t */ if (((intptr_t)data) & 0x3f) { p2 = malloc(size); - if (p2 == NULL) + if (p2 == NULL) { ERROR(disk, "allocate bounce buffer"); + return (-1); + } memcpy(p2, data, size); data = p2; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200904021716.n32HGdE0070869>