]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfsprogs: unhandled error check in libxfs_trans_read_buf
authorAjeet Yadav <ajeet.yadav.77@gmail.com>
Thu, 3 Feb 2011 06:17:24 +0000 (06:17 +0000)
committerAlex Elder <aelder@sgi.com>
Tue, 22 Feb 2011 01:35:26 +0000 (19:35 -0600)
libxfs_trans_read_buf() is used in both mkfs.xfs & xfs_repair.
During stability testing we found some time occur pagefault in
mkfs.xfs, code inspection shows that if libxfs_readbuf() fails then
occurs a page fault in xfs_buf_item_init() called in
libxfs_trans_read_buf().

mkfs.xfs: unhandled page fault (11) at 0x00000070, code 0x017

Added NULL check and errno handling.

Signed-off-by: Ajeet Yadav <ajeet.yadav.77@gmail.com>
Signed-off-by: Alex Elder <aelder@sgi.com>
libxfs/rdwr.c
libxfs/trans.c

index 77d0451839b33cc459a1592eeda8103187b77f47..ec2675e22428a1ed3c408e79cdb7cfbc73514672 100644 (file)
@@ -207,9 +207,11 @@ libxfs_trace_readbuf(const char *func, const char *file, int line, dev_t dev, xf
 {
        xfs_buf_t       *bp = libxfs_readbuf(dev, blkno, len, flags);
 
-       bp->b_func = func;
-       bp->b_file = file;
-       bp->b_line = line;
+       if (bp){
+               bp->b_func = func;
+               bp->b_file = file;
+               bp->b_line = line;
+       }
 
        return bp;
 }
index 1c60f382aa312ac173b47af9cb3a0a88a02bb017..3ed2795f459637cf9215db397e8c127a68bfcdbe 100644 (file)
@@ -508,6 +508,10 @@ libxfs_trans_read_buf(
        }
 
        bp = libxfs_readbuf(dev, blkno, len, flags);
+       if (!bp){
+               *bpp = NULL;
+               return errno;
+       }
 #ifdef XACT_DEBUG
        fprintf(stderr, "trans_read_buf buffer %p, transaction %p\n", bp, tp);
 #endif