Whamcloud - gitweb
LU-3042 build: fix 'NULL pointer dereference' errors
[fs/lustre-release.git] / lustre / llite / dir.c
index 0496b01..35f6810 100644 (file)
@@ -595,7 +595,7 @@ static int ll_readdir(struct file *filp, void *cookie, filldir_t filldir)
        struct inode            *inode  = filp->f_dentry->d_inode;
        struct ll_file_data     *lfd    = LUSTRE_FPRIVATE(filp);
        struct ll_sb_info       *sbi    = ll_i2sbi(inode);
-       __u64                   pos     = lfd->lfd_pos;
+       __u64                   pos;
        int                     hash64  = sbi->ll_flags & LL_SBI_64BIT_HASH;
        int                     api32   = ll_need_32bit_api(sbi);
        int                     rc;
@@ -604,6 +604,11 @@ static int ll_readdir(struct file *filp, void *cookie, filldir_t filldir)
 #endif
        ENTRY;
 
+       if (lfd != NULL)
+               pos = lfd->lfd_pos;
+       else
+               pos = 0;
+
        CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p) pos %lu/%llu "
               " 32bit_api %d\n", inode->i_ino, inode->i_generation,
               inode, (unsigned long)pos, i_size_read(inode), api32);
@@ -615,7 +620,8 @@ static int ll_readdir(struct file *filp, void *cookie, filldir_t filldir)
                GOTO(out, rc = 0);
 
        rc = ll_dir_read(inode, &pos, cookie, filldir);
-       lfd->lfd_pos = pos;
+       if (lfd != NULL)
+               lfd->lfd_pos = pos;
         if (pos == MDS_DIR_END_OFF) {
                 if (api32)
                         filp->f_pos = LL_DIR_END_OFF_32BIT;
@@ -1453,7 +1459,7 @@ free_lmv:
                 * on 2.4, we use OBD_CONNECT_LVB_TYPE to detect whether the
                 * server will support REINT_RMENTRY XXX*/
                if (!(exp_connect_flags(sbi->ll_md_exp) & OBD_CONNECT_LVB_TYPE))
-                       return -ENOTSUPP;
+                       RETURN(-ENOTSUPP);
 
                filename = ll_getname((const char *)arg);
                if (IS_ERR(filename))