提交 2a30f36d 编写于 作者: C Chandra Seetharaman 提交者: Alex Elder

xfs: Check the return value of xfs_trans_get_buf()

Check the return value of xfs_trans_get_buf() and fail
appropriately.
Signed-off-by: NChandra Seetharaman <sekharan@us.ibm.com>
Signed-off-by: NAlex Elder <aelder@sgi.com>
上级 b522950f
...@@ -2948,6 +2948,8 @@ xfs_attr_leaf_freextent(xfs_trans_t **trans, xfs_inode_t *dp, ...@@ -2948,6 +2948,8 @@ xfs_attr_leaf_freextent(xfs_trans_t **trans, xfs_inode_t *dp,
bp = xfs_trans_get_buf(*trans, bp = xfs_trans_get_buf(*trans,
dp->i_mount->m_ddev_targp, dp->i_mount->m_ddev_targp,
dblkno, dblkcnt, XBF_LOCK); dblkno, dblkcnt, XBF_LOCK);
if (!bp)
return ENOMEM;
xfs_trans_binval(*trans, bp); xfs_trans_binval(*trans, bp);
/* /*
* Roll to next transaction. * Roll to next transaction.
......
...@@ -970,7 +970,8 @@ xfs_btree_get_buf_block( ...@@ -970,7 +970,8 @@ xfs_btree_get_buf_block(
*bpp = xfs_trans_get_buf(cur->bc_tp, mp->m_ddev_targp, d, *bpp = xfs_trans_get_buf(cur->bc_tp, mp->m_ddev_targp, d,
mp->m_bsize, flags); mp->m_bsize, flags);
ASSERT(!xfs_buf_geterror(*bpp)); if (!*bpp)
return ENOMEM;
*block = XFS_BUF_TO_BLOCK(*bpp); *block = XFS_BUF_TO_BLOCK(*bpp);
return 0; return 0;
......
...@@ -402,8 +402,11 @@ xfs_qm_dqalloc( ...@@ -402,8 +402,11 @@ xfs_qm_dqalloc(
dqp->q_blkno, dqp->q_blkno,
mp->m_quotainfo->qi_dqchunklen, mp->m_quotainfo->qi_dqchunklen,
0); 0);
if (!bp || (error = xfs_buf_geterror(bp)))
error = xfs_buf_geterror(bp);
if (error)
goto error1; goto error1;
/* /*
* Make a chunk of dquots out of this buffer and log * Make a chunk of dquots out of this buffer and log
* the entire thing. * the entire thing.
......
...@@ -150,7 +150,7 @@ xfs_check_agi_freecount( ...@@ -150,7 +150,7 @@ xfs_check_agi_freecount(
/* /*
* Initialise a new set of inodes. * Initialise a new set of inodes.
*/ */
STATIC void STATIC int
xfs_ialloc_inode_init( xfs_ialloc_inode_init(
struct xfs_mount *mp, struct xfs_mount *mp,
struct xfs_trans *tp, struct xfs_trans *tp,
...@@ -202,8 +202,8 @@ xfs_ialloc_inode_init( ...@@ -202,8 +202,8 @@ xfs_ialloc_inode_init(
fbuf = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, fbuf = xfs_trans_get_buf(tp, mp->m_ddev_targp, d,
mp->m_bsize * blks_per_cluster, mp->m_bsize * blks_per_cluster,
XBF_LOCK); XBF_LOCK);
ASSERT(!xfs_buf_geterror(fbuf)); if (!fbuf)
return ENOMEM;
/* /*
* Initialize all inodes in this buffer and then log them. * Initialize all inodes in this buffer and then log them.
* *
...@@ -225,6 +225,7 @@ xfs_ialloc_inode_init( ...@@ -225,6 +225,7 @@ xfs_ialloc_inode_init(
} }
xfs_trans_inode_alloc_buf(tp, fbuf); xfs_trans_inode_alloc_buf(tp, fbuf);
} }
return 0;
} }
/* /*
...@@ -369,9 +370,11 @@ xfs_ialloc_ag_alloc( ...@@ -369,9 +370,11 @@ xfs_ialloc_ag_alloc(
* rather than a linear progression to prevent the next generation * rather than a linear progression to prevent the next generation
* number from being easily guessable. * number from being easily guessable.
*/ */
xfs_ialloc_inode_init(args.mp, tp, agno, args.agbno, args.len, error = xfs_ialloc_inode_init(args.mp, tp, agno, args.agbno,
random32()); args.len, random32());
if (error)
return error;
/* /*
* Convert the results. * Convert the results.
*/ */
......
...@@ -1644,7 +1644,7 @@ xfs_iunlink_remove( ...@@ -1644,7 +1644,7 @@ xfs_iunlink_remove(
* inodes that are in memory - they all must be marked stale and attached to * inodes that are in memory - they all must be marked stale and attached to
* the cluster buffer. * the cluster buffer.
*/ */
STATIC void STATIC int
xfs_ifree_cluster( xfs_ifree_cluster(
xfs_inode_t *free_ip, xfs_inode_t *free_ip,
xfs_trans_t *tp, xfs_trans_t *tp,
...@@ -1690,6 +1690,8 @@ xfs_ifree_cluster( ...@@ -1690,6 +1690,8 @@ xfs_ifree_cluster(
mp->m_bsize * blks_per_cluster, mp->m_bsize * blks_per_cluster,
XBF_LOCK); XBF_LOCK);
if (!bp)
return ENOMEM;
/* /*
* Walk the inodes already attached to the buffer and mark them * Walk the inodes already attached to the buffer and mark them
* stale. These will all have the flush locks held, so an * stale. These will all have the flush locks held, so an
...@@ -1799,6 +1801,7 @@ xfs_ifree_cluster( ...@@ -1799,6 +1801,7 @@ xfs_ifree_cluster(
} }
xfs_perag_put(pag); xfs_perag_put(pag);
return 0;
} }
/* /*
...@@ -1878,10 +1881,10 @@ xfs_ifree( ...@@ -1878,10 +1881,10 @@ xfs_ifree(
dip->di_mode = 0; dip->di_mode = 0;
if (delete) { if (delete) {
xfs_ifree_cluster(ip, tp, first_ino); error = xfs_ifree_cluster(ip, tp, first_ino);
} }
return 0; return error;
} }
/* /*
......
...@@ -308,6 +308,10 @@ xfs_inactive_symlink_rmt( ...@@ -308,6 +308,10 @@ xfs_inactive_symlink_rmt(
bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, bp = xfs_trans_get_buf(tp, mp->m_ddev_targp,
XFS_FSB_TO_DADDR(mp, mval[i].br_startblock), XFS_FSB_TO_DADDR(mp, mval[i].br_startblock),
XFS_FSB_TO_BB(mp, mval[i].br_blockcount), 0); XFS_FSB_TO_BB(mp, mval[i].br_blockcount), 0);
if (!bp) {
error = ENOMEM;
goto error1;
}
xfs_trans_binval(tp, bp); xfs_trans_binval(tp, bp);
} }
/* /*
...@@ -1648,7 +1652,10 @@ xfs_symlink( ...@@ -1648,7 +1652,10 @@ xfs_symlink(
byte_cnt = XFS_FSB_TO_B(mp, mval[n].br_blockcount); byte_cnt = XFS_FSB_TO_B(mp, mval[n].br_blockcount);
bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d,
BTOBB(byte_cnt), 0); BTOBB(byte_cnt), 0);
ASSERT(!xfs_buf_geterror(bp)); if (!bp) {
error = ENOMEM;
goto error2;
}
if (pathlen < byte_cnt) { if (pathlen < byte_cnt) {
byte_cnt = pathlen; byte_cnt = pathlen;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册