[PATCH 1/1] XFS: __xfs_get_blocks check pointer to the target device

Ramon de Carvalho Valle
2009-08-03T20:01:54Z

[-- Attachment #1.1: Type: text/plain, Size: 976 bytes --]

The __xfs_get_blocks function does not check if the pointer to the target
device is valid before dereferencing it.

Signed-off-by: Ramon de Carvalho Valle <ramon@risesecurity.org>
Cc: stable <stable@kernel.org>
---
fs/xfs/linux-2.6/xfs_aops.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c
index aecf251..bf482d5 100644
--- a/fs/xfs/linux-2.6/xfs_aops.c
+++ b/fs/xfs/linux-2.6/xfs_aops.c
@@ -1419,7 +1419,11 @@ __xfs_get_blocks(
* If this is a realtime file, data may be on a different device.
* to that pointed to from the buffer_head b_bdev currently.
*/
- bh_result->b_bdev = iomap.iomap_target->bt_bdev;
+ if (!iomap.iomap_target)
+ return -XFS_ERROR(EIO);
+
+ if (iomap.iomap_flags & IOMAP_REALTIME)
+ bh_result->b_bdev = iomap.iomap_target->bt_bdev;

/*
* If we previously allocated a block out beyond eof and we are now
--
1.5.6.3