Skip to content

Commit

Permalink
ceph: avoid possible null deref in readdir after dir llseek
Browse files Browse the repository at this point in the history
last may be NULL, but we dereference it in the else branch without
checking.  Normally it doesn't trigger because last == NULL when fpos == 2,
but it could happen on a newly opened dir if the user seeks forward.

Reported-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Sage Weil <sage@newdream.net>
  • Loading branch information
Sage Weil committed Dec 1, 2010
1 parent 3561d43 commit 884ea89
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fs/ceph/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ static int __dcache_readdir(struct file *filp,
spin_lock(&dcache_lock);

/* start at beginning? */
if (filp->f_pos == 2 || (last &&
filp->f_pos < ceph_dentry(last)->offset)) {
if (filp->f_pos == 2 || last == NULL ||
filp->f_pos < ceph_dentry(last)->offset) {
if (list_empty(&parent->d_subdirs))
goto out_unlock;
p = parent->d_subdirs.prev;
Expand Down

0 comments on commit 884ea89

Please sign in to comment.