]> git.karo-electronics.de Git - linux-beck.git/commitdiff
xfs: Check the return value of xfs_trans_get_buf()
authorChandra Seetharaman <sekharan@us.ibm.com>
Tue, 20 Sep 2011 13:56:55 +0000 (13:56 +0000)
committerAlex Elder <aelder@sgi.com>
Wed, 12 Oct 2011 02:15:01 +0000 (21:15 -0500)
Check the return value of xfs_trans_get_buf() and fail
appropriately.

Signed-off-by: Chandra Seetharaman <sekharan@us.ibm.com>
Signed-off-by: Alex Elder <aelder@sgi.com>
fs/xfs/xfs_attr_leaf.c
fs/xfs/xfs_btree.c
fs/xfs/xfs_dquot.c
fs/xfs/xfs_ialloc.c
fs/xfs/xfs_inode.c
fs/xfs/xfs_vnodeops.c

index 8fad9602542bb4cf0fe5550ea1b970a1b7c0a3f9..58c3add07b65b9c68beb55db81c69b79f86046da 100644 (file)
@@ -2948,6 +2948,8 @@ xfs_attr_leaf_freextent(xfs_trans_t **trans, xfs_inode_t *dp,
                        bp = xfs_trans_get_buf(*trans,
                                        dp->i_mount->m_ddev_targp,
                                        dblkno, dblkcnt, XBF_LOCK);
+                       if (!bp)
+                               return ENOMEM;
                        xfs_trans_binval(*trans, bp);
                        /*
                         * Roll to next transaction.
index 2b9fd385e27dbd93e91b7e4d90cd1a81bc86f7af..28cc0199dc1f2c2708ba2108f70877915ad7e027 100644 (file)
@@ -970,7 +970,8 @@ xfs_btree_get_buf_block(
        *bpp = xfs_trans_get_buf(cur->bc_tp, mp->m_ddev_targp, d,
                                 mp->m_bsize, flags);
 
-       ASSERT(!xfs_buf_geterror(*bpp));
+       if (!*bpp)
+               return ENOMEM;
 
        *block = XFS_BUF_TO_BLOCK(*bpp);
        return 0;
index 3e2ccaedc51e15d9fac8716d264b3e5c7873b254..0c5fe66ce92be75d3b337cdd27b99ae09a6b0b7e 100644 (file)
@@ -402,8 +402,11 @@ xfs_qm_dqalloc(
                               dqp->q_blkno,
                               mp->m_quotainfo->qi_dqchunklen,
                               0);
-       if (!bp || (error = xfs_buf_geterror(bp)))
+
+       error = xfs_buf_geterror(bp);
+       if (error)
                goto error1;
+
        /*
         * Make a chunk of dquots out of this buffer and log
         * the entire thing.
index 9f24ec28283bfa1ea237efc3f43a03c480999403..207e0b0c0730a8b47a8625e45408620908edcc19 100644 (file)
@@ -150,7 +150,7 @@ xfs_check_agi_freecount(
 /*
  * Initialise a new set of inodes.
  */
-STATIC void
+STATIC int
 xfs_ialloc_inode_init(
        struct xfs_mount        *mp,
        struct xfs_trans        *tp,
@@ -202,8 +202,8 @@ xfs_ialloc_inode_init(
                fbuf = xfs_trans_get_buf(tp, mp->m_ddev_targp, d,
                                         mp->m_bsize * blks_per_cluster,
                                         XBF_LOCK);
-               ASSERT(!xfs_buf_geterror(fbuf));
-
+               if (!fbuf)
+                       return ENOMEM;
                /*
                 * Initialize all inodes in this buffer and then log them.
                 *
@@ -225,6 +225,7 @@ xfs_ialloc_inode_init(
                }
                xfs_trans_inode_alloc_buf(tp, fbuf);
        }
+       return 0;
 }
 
 /*
@@ -369,9 +370,11 @@ xfs_ialloc_ag_alloc(
         * rather than a linear progression to prevent the next generation
         * number from being easily guessable.
         */
-       xfs_ialloc_inode_init(args.mp, tp, agno, args.agbno, args.len,
-                             random32());
+       error = xfs_ialloc_inode_init(args.mp, tp, agno, args.agbno,
+                       args.len, random32());
 
+       if (error)
+               return error;
        /*
         * Convert the results.
         */
index 7f237ba3c29284195849475739d3562131e4faeb..d689253fdfdad3760ec1f4226d1cbec55477d217 100644 (file)
@@ -1644,7 +1644,7 @@ xfs_iunlink_remove(
  * inodes that are in memory - they all must be marked stale and attached to
  * the cluster buffer.
  */
-STATIC void
+STATIC int
 xfs_ifree_cluster(
        xfs_inode_t     *free_ip,
        xfs_trans_t     *tp,
@@ -1690,6 +1690,8 @@ xfs_ifree_cluster(
                                        mp->m_bsize * blks_per_cluster,
                                        XBF_LOCK);
 
+               if (!bp)
+                       return ENOMEM;
                /*
                 * Walk the inodes already attached to the buffer and mark them
                 * stale. These will all have the flush locks held, so an
@@ -1799,6 +1801,7 @@ retry:
        }
 
        xfs_perag_put(pag);
+       return 0;
 }
 
 /*
@@ -1878,10 +1881,10 @@ xfs_ifree(
        dip->di_mode = 0;
 
        if (delete) {
-               xfs_ifree_cluster(ip, tp, first_ino);
+               error = xfs_ifree_cluster(ip, tp, first_ino);
        }
 
-       return 0;
+       return error;
 }
 
 /*
index c2ff0fc86567be1c359687b09d1761c6b947cabb..0d1caec873a13f237b84d79eb4cada61d386d1d1 100644 (file)
@@ -308,6 +308,10 @@ xfs_inactive_symlink_rmt(
                bp = xfs_trans_get_buf(tp, mp->m_ddev_targp,
                        XFS_FSB_TO_DADDR(mp, mval[i].br_startblock),
                        XFS_FSB_TO_BB(mp, mval[i].br_blockcount), 0);
+               if (!bp) {
+                       error = ENOMEM;
+                       goto error1;
+               }
                xfs_trans_binval(tp, bp);
        }
        /*
@@ -1648,7 +1652,10 @@ xfs_symlink(
                        byte_cnt = XFS_FSB_TO_B(mp, mval[n].br_blockcount);
                        bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d,
                                               BTOBB(byte_cnt), 0);
-                       ASSERT(!xfs_buf_geterror(bp));
+                       if (!bp) {
+                               error = ENOMEM;
+                               goto error2;
+                       }
                        if (pathlen < byte_cnt) {
                                byte_cnt = pathlen;
                        }