diff options
author | Chandra Seetharaman <sekharan@us.ibm.com> | 2011-08-02 22:18:29 -0400 |
---|---|---|
committer | Alex Elder <aelder@sgi.com> | 2011-08-12 14:39:29 -0400 |
commit | ac4d6888b21a8be373f3e06f1d4011fbe2bbbeac (patch) | |
tree | 6a39e3be9bcf99cddc0ce0b0ed15aac794b527f8 /fs | |
parent | 9e978d8f7db1c5de7cdc6450a8ca208db3b95f84 (diff) |
xfs: Check the return value of xfs_buf_read() for NULL
Check the return value of xfs_buf_read() for NULL and return ENOMEM
if it is NULL. This is necessary in a few spots to avoid subsequent
code blindly dereferencing the null buffer pointer.
Signed-off-by: Chandra Seetharaman <sekharan@us.ibm.com>
Signed-off-by: Alex Elder <aelder@sgi.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/xfs/xfs_log_recover.c | 6 | ||||
-rw-r--r-- | fs/xfs/xfs_vnodeops.c | 2 |
2 files changed, 8 insertions, 0 deletions
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index 1076b7effcdc..b9afff8a1be2 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c | |||
@@ -2131,6 +2131,8 @@ xlog_recover_buffer_pass2( | |||
2131 | 2131 | ||
2132 | bp = xfs_buf_read(mp->m_ddev_targp, buf_f->blf_blkno, buf_f->blf_len, | 2132 | bp = xfs_buf_read(mp->m_ddev_targp, buf_f->blf_blkno, buf_f->blf_len, |
2133 | buf_flags); | 2133 | buf_flags); |
2134 | if (!bp) | ||
2135 | return XFS_ERROR(ENOMEM); | ||
2134 | error = xfs_buf_geterror(bp); | 2136 | error = xfs_buf_geterror(bp); |
2135 | if (error) { | 2137 | if (error) { |
2136 | xfs_ioerror_alert("xlog_recover_do..(read#1)", mp, | 2138 | xfs_ioerror_alert("xlog_recover_do..(read#1)", mp, |
@@ -2222,6 +2224,10 @@ xlog_recover_inode_pass2( | |||
2222 | 2224 | ||
2223 | bp = xfs_buf_read(mp->m_ddev_targp, in_f->ilf_blkno, in_f->ilf_len, | 2225 | bp = xfs_buf_read(mp->m_ddev_targp, in_f->ilf_blkno, in_f->ilf_len, |
2224 | XBF_LOCK); | 2226 | XBF_LOCK); |
2227 | if (!bp) { | ||
2228 | error = ENOMEM; | ||
2229 | goto error; | ||
2230 | } | ||
2225 | error = xfs_buf_geterror(bp); | 2231 | error = xfs_buf_geterror(bp); |
2226 | if (error) { | 2232 | if (error) { |
2227 | xfs_ioerror_alert("xlog_recover_do..(read#2)", mp, | 2233 | xfs_ioerror_alert("xlog_recover_do..(read#2)", mp, |
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c index dd05360ad56f..2a432d00d4c1 100644 --- a/fs/xfs/xfs_vnodeops.c +++ b/fs/xfs/xfs_vnodeops.c | |||
@@ -83,6 +83,8 @@ xfs_readlink_bmap( | |||
83 | 83 | ||
84 | bp = xfs_buf_read(mp->m_ddev_targp, d, BTOBB(byte_cnt), | 84 | bp = xfs_buf_read(mp->m_ddev_targp, d, BTOBB(byte_cnt), |
85 | XBF_LOCK | XBF_MAPPED | XBF_DONT_BLOCK); | 85 | XBF_LOCK | XBF_MAPPED | XBF_DONT_BLOCK); |
86 | if (!bp) | ||
87 | return XFS_ERROR(ENOMEM); | ||
86 | error = xfs_buf_geterror(bp); | 88 | error = xfs_buf_geterror(bp); |
87 | if (error) { | 89 | if (error) { |
88 | xfs_ioerror_alert("xfs_readlink", | 90 | xfs_ioerror_alert("xfs_readlink", |