Skip to content

Commit

Permalink
ocfs2: Check search result in ocfs2_xattr_block_get()
Browse files Browse the repository at this point in the history
ocfs2_xattr_block_get() calls ocfs2_xattr_search() to find an external
xattr, but doesn't check the search result that is passed back via struct
ocfs2_xattr_search. Add a check for search result, and pass back -ENODATA if
the xattr search failed. This avoids a later NULL pointer error.

Signed-off-by: Tiger Yang <tiger.yang@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
  • Loading branch information
Tiger Yang authored and Mark Fasheh committed Nov 10, 2008
1 parent de29c08 commit 6c1e183
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion fs/ocfs2/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 6c1e183

Please sign in to comment.