Skip to contentSkip to conversation

ocfs2: add search result checking in block_get

PATCH New Tiger Yang 2 participants 2 messages Nov 2, 2008 – Nov 4, 2008 OCFS2

lore
Share & tools
lore

Tiger Yang

author
#0 lore raw

PATCH 1/1 ocfs2: add search result checking in block_get

Because ocfs2_xattr_block_find may return zero when not found the xattr entry, and struct ocfs2_xattr_search may have not be initialized. So check the search result is necessary to avoid access NULL pointer.

---
 fs/ocfs2/xattr.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
fs/ocfs2/xattr.c +6 -1
index 70baffe..054e2ef 100644
@@ -777,6 +777,11 @@ static int ocfs2_xattr_block_get(struct inode *inode,
 		goto cleanup;
 	}
 
+	if (xs->not_found) {
+		ret = -ENODATA;
+		goto cleanup;
+	}
+
 	xb = (struct ocfs2_xattr_block *)xs->xattr_bh->b_data;
 	size = le64_to_cpu(xs->here->xe_value_size);
 	if (buffer) {
@@ -860,7 +865,7 @@ static int ocfs2_xattr_get(struct inode *inode,
 	down_read(&oi->ip_xattr_sem);
 	ret = ocfs2_xattr_ibody_get(inode, name_index, name, buffer,
 				    buffer_size, &xis);
-	if (ret == -ENODATA)
+	if (ret == -ENODATA && di->i_xattr_loc)
 		ret = ocfs2_xattr_block_get(inode, name_index, name, buffer,
 					    buffer_size, &xbs);
 	up_read(&oi->ip_xattr_sem);
Signature · 1 line
1.5.4.1
#1 lore raw

PATCH 1/1 ocfs2: add search result checking in block_get

Quoted 4 lines · Tiger Yang

Because ocfs2_xattr_block_find may return zero when not found the xattr entry, and struct ocfs2_xattr_search may have not be initialized. So check the search result is necessary to avoid access NULL pointer.

Ok, thanks. This is now in the fixes branch.

	--Mark

--
Mark Fasheh