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

From: Ramon de Carvalho Valle
Date: Mon Aug 03 2009 - 16:09:32 EST


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@xxxxxxxxxxxxxxxx>
Cc: stable <stable@xxxxxxxxxx>
---
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

Attachment: signature.asc
Description: This is a digitally signed message part