gfs2-utils: master - libgfs2: Fix null pointer dereference in linked_leaf_search

Andrew Price andyp at fedoraproject.org
Tue Sep 6 16:57:39 UTC 2011


Gitweb:        http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitdiff;h=35a6232630c764fb1c33e0a28fdc8edf556aa9d8
Commit:        35a6232630c764fb1c33e0a28fdc8edf556aa9d8
Parent:        355e6e070ed0763312bf3ac149ac8ab021e9d7c3
Author:        Andrew Price <anprice at redhat.com>
AuthorDate:    Tue Sep 6 17:29:07 2011 +0100
Committer:     Andrew Price <anprice at redhat.com>
CommitterDate: Tue Sep 6 17:29:07 2011 +0100

libgfs2: Fix null pointer dereference in linked_leaf_search

Fix a null pointer dereference by checking the value of the bh set by
get_first_leaf(). Looking down the call tree the bh is set to NULL when
__bread fails to allocate memory so we can use errno as the return value
here.

Signed-off-by: Andrew Price <anprice at redhat.com>
---
 gfs2/libgfs2/fs_ops.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index d344bc4..ecd54ca 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -1510,6 +1510,8 @@ static int linked_leaf_search(struct gfs2_inode *dip, const char *filename,
 	error = get_first_leaf(dip, lindex, &bh_next);
 	if (error)
 		return error;
+	if (bh_next == NULL)
+		return errno;
 
 	/*  Find the entry  */
 	do{


More information about the cluster-commits mailing list