xfs
[Top] [All Lists]

[patch] xfsprogs: unhandled error check in libxfs_trans_read_buf

To: xfs@xxxxxxxxxxx, Eric Sandeen <sandeen@xxxxxxxxxxx>
Subject: [patch] xfsprogs: unhandled error check in libxfs_trans_read_buf
From: Ajeet Yadav <ajeet.yadav.77@xxxxxxxxx>
Date: Thu, 3 Feb 2011 15:17:24 +0900
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=OZp6S1RMCl2aJ/KzIj67Is3oOWS3fvWmFZOVWapSCFE=; b=w8jC4uDGCFdiaC7ay2Qgg29C/37iIQQGHr2/sWD3BEngLwoNkHUictpgXaJtZNgCbk NT85DKFup24ikWDjUPpDn+Xohhs0X25Auc96Y4ctjP1pme8enBpumyFmr3IT0YbACm5Y R1xB8CEE7RsbqwZpMHNVKTe7DGDCJz1akz+mc=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=wxAAHa/IZ3tT+XfAjBurFWHhPSsvcU+UkFW1n+CeToCBNRZ9l2SqcTc8EvuG8miXID xJoL1HiD4AbWSTAl+idqH073DWaYy6MYCsi11ayjFyECWJlq/s7eDiilGx2nJ+7FBry6 uXab0LxaInMOGl8t+N+j5OpRgswxcxahVH3Y0=
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 <ajeet.yadav.77@xxxxxxxxx>

diff -Nurp xfsprogs/libxfs/rdwr.c xfsprogs-dirty/libxfs/rdwr.c
--- xfsprogs/libxfs/rdwr.c      2011-01-28 20:22:11.000000000 +0900
+++ xfsprogs-dirty/libxfs/rdwr.c        2011-02-02 16:59:16.000000000 +0900
@@ -207,10 +207,11 @@ libxfs_trace_readbuf(const char *func, c
 {
        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;
 }

@@ -485,6 +486,7 @@ libxfs_readbuf(dev_t dev, xfs_daddr_t bl
                error = libxfs_readbufr(dev, blkno, bp, len, flags);
                if (error) {
                        libxfs_putbuf(bp);
+                       errno = error;
                        return NULL;
                }
        }
diff -Nurp xfsprogs/libxfs/trans.c xfsprogs-dirty/libxfs/trans.c
--- xfsprogs/libxfs/trans.c     2011-01-28 20:22:11.000000000 +0900
+++ xfsprogs-dirty/libxfs/trans.c       2011-02-02 17:00:42.000000000 +0900
@@ -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

<Prev in Thread] Current Thread [Next in Thread>