svn commit: r192996 - stable/6/lib/libufs
Xin LI
delphij at FreeBSD.org
Thu May 28 21:19:23 UTC 2009
Author: delphij
Date: Thu May 28 21:19:21 2009
New Revision: 192996
URL: http://svn.freebsd.org/changeset/base/192996
Log:
Merge r190646:
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:
stable/6/lib/libufs/ (props changed)
stable/6/lib/libufs/block.c
Modified: stable/6/lib/libufs/block.c
==============================================================================
--- stable/6/lib/libufs/block.c Thu May 28 21:17:27 2009 (r192995)
+++ stable/6/lib/libufs/block.c Thu May 28 21:19:21 2009 (r192996)
@@ -63,8 +63,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) {
@@ -114,8 +116,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;
}
More information about the svn-src-stable-6
mailing list