From: Ajeet Yadav Date: Thu, 3 Feb 2011 06:17:24 +0000 (+0000) Subject: xfsprogs: unhandled error check in libxfs_trans_read_buf X-Git-Tag: v3.1.5~25 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d87e8a45d9a3b4ed066f1d3358c78d66ab475255;p=thirdparty%2Fxfsprogs-dev.git xfsprogs: unhandled error check in libxfs_trans_read_buf 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 Signed-off-by: Alex Elder --- diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c index 77d045183..ec2675e22 100644 --- a/libxfs/rdwr.c +++ b/libxfs/rdwr.c @@ -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; } diff --git a/libxfs/trans.c b/libxfs/trans.c index 1c60f382a..3ed2795f4 100644 --- a/libxfs/trans.c +++ b/libxfs/trans.c @@ -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