]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/gfs2/ops_dentry.c
old buffer overflow in moxa driver
[linux-2.6-omap-h63xx.git] / fs / gfs2 / ops_dentry.c
index d355899585d822b800d15f2d8826734bc2d02a6f..a6fdc52f554a43d5d195a8282319028d63d54873 100644 (file)
@@ -7,12 +7,10 @@
  * of the GNU General Public License version 2.
  */
 
-#include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/completion.h>
 #include <linux/buffer_head.h>
-#include <linux/smp_lock.h>
 #include <linux/gfs2_ondisk.h>
 #include <linux/crc32.h>
 #include <linux/lm_interface.h>
@@ -46,6 +44,7 @@ static int gfs2_drevalidate(struct dentry *dentry, struct nameidata *nd)
        struct gfs2_inum_host inum;
        unsigned int type;
        int error;
+       int had_lock=0;
 
        if (inode && is_bad_inode(inode))
                goto invalid;
@@ -53,9 +52,12 @@ static int gfs2_drevalidate(struct dentry *dentry, struct nameidata *nd)
        if (sdp->sd_args.ar_localcaching)
                goto valid;
 
-       error = gfs2_glock_nq_init(dip->i_gl, LM_ST_SHARED, 0, &d_gh);
-       if (error)
-               goto fail;
+       had_lock = gfs2_glock_is_locked_by_me(dip->i_gl);
+       if (!had_lock) {
+               error = gfs2_glock_nq_init(dip->i_gl, LM_ST_SHARED, 0, &d_gh);
+               if (error)
+                       goto fail;
+       } 
 
        error = gfs2_dir_search(parent->d_inode, &dentry->d_name, &inum, &type);
        switch (error) {
@@ -82,13 +84,15 @@ static int gfs2_drevalidate(struct dentry *dentry, struct nameidata *nd)
        }
 
 valid_gunlock:
-       gfs2_glock_dq_uninit(&d_gh);
+       if (!had_lock)
+               gfs2_glock_dq_uninit(&d_gh);
 valid:
        dput(parent);
        return 1;
 
 invalid_gunlock:
-       gfs2_glock_dq_uninit(&d_gh);
+       if (!had_lock)
+               gfs2_glock_dq_uninit(&d_gh);
 invalid:
        if (inode && S_ISDIR(inode->i_mode)) {
                if (have_submounts(dentry))