From: Sage Weil Date: Tue, 23 Nov 2010 06:58:06 +0000 (-0800) Subject: ceph: avoid possible null deref in readdir after dir llseek X-Git-Tag: upstream/snapshot3+hdmi~12227^2~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=884ea892763d4dfba509743f65961c782c0442db;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git ceph: avoid possible null deref in readdir after dir llseek 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 Signed-off-by: Sage Weil --- diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index 7d447af..158c700 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -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;