diff mbox

add check for nameidata before accessing it

Message ID 4a4634330911191305q69e98671qfa4089592cdd71cf@mail.gmail.com
State New
Headers show

Commit Message

Shirish Pargaonkar Nov. 19, 2009, 9:05 p.m. UTC
This should prevent oops reported in kernel bugzilla 14641

From 240f75430dbe4965f79d903309488ebabd3d3625 Mon Sep 17 00:00:00 2001
From: Shirish Pargaonkar <shirishpargaonkar@gmail.com>
Date: Thu, 19 Nov 2009 14:38:59 -0600
Subject: [PATCH] add check for nameidata before accessing it

Cc: Stable <stable@kernel.org>
---
 fs/cifs/dir.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

        }
@@ -675,7 +675,7 @@ cifs_lookup(struct inode *parent_dir_inode, struct
dentry *direntry,
         * reduction in network traffic in the other paths.
         */
        if (pTcon->unix_ext) {
-               if (!(nd->flags & (LOOKUP_PARENT | LOOKUP_DIRECTORY)) &&
+               if (nd && !(nd->flags & (LOOKUP_PARENT | LOOKUP_DIRECTORY)) &&
                     (nd->flags & LOOKUP_OPEN) && !pTcon->broken_posix_open &&
                     (nd->intent.open.flags & O_CREAT)) {
                        rc = cifs_posix_open(full_path, &newInode, nd->path.mnt,
--
1.6.0.2

Comments

Jeff Layton Nov. 19, 2009, 10:12 p.m. UTC | #1
On Thu, 19 Nov 2009 15:05:45 -0600
Shirish Pargaonkar <shirishpargaonkar@gmail.com> wrote:

> This should prevent oops reported in kernel bugzilla 14641
> 
> From 240f75430dbe4965f79d903309488ebabd3d3625 Mon Sep 17 00:00:00 2001
> From: Shirish Pargaonkar <shirishpargaonkar@gmail.com>
> Date: Thu, 19 Nov 2009 14:38:59 -0600
> Subject: [PATCH] add check for nameidata before accessing it
> 
> Cc: Stable <stable@kernel.org>
> ---
>  fs/cifs/dir.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
> index 627a60a..32771f5 100644
> --- a/fs/cifs/dir.c
> +++ b/fs/cifs/dir.c
> @@ -643,7 +643,7 @@ cifs_lookup(struct inode *parent_dir_inode, struct
> dentry *direntry,
>          * O_EXCL: optimize away the lookup, but don't hash the dentry. Let
>          * the VFS handle the create.
>          */
> -       if (nd->flags & LOOKUP_EXCL) {
> +       if (nd && (nd->flags & LOOKUP_EXCL)) {
>                 d_instantiate(direntry, NULL);
>                 return 0;
>         }
> @@ -675,7 +675,7 @@ cifs_lookup(struct inode *parent_dir_inode, struct
> dentry *direntry,
>          * reduction in network traffic in the other paths.
>          */
>         if (pTcon->unix_ext) {
> -               if (!(nd->flags & (LOOKUP_PARENT | LOOKUP_DIRECTORY)) &&
> +               if (nd && !(nd->flags & (LOOKUP_PARENT | LOOKUP_DIRECTORY)) &&
>                      (nd->flags & LOOKUP_OPEN) && !pTcon->broken_posix_open &&
>                      (nd->intent.open.flags & O_CREAT)) {
>                         rc = cifs_posix_open(full_path, &newInode, nd->path.mnt,
> --
> 1.6.0.2

Once the line-wrapping is fixed...

Acked-by: Jeff Layton <jlayton@redhat.com>
diff mbox

Patch

diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index 627a60a..32771f5 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -643,7 +643,7 @@  cifs_lookup(struct inode *parent_dir_inode, struct
dentry *direntry,
         * O_EXCL: optimize away the lookup, but don't hash the dentry. Let
         * the VFS handle the create.
         */
-       if (nd->flags & LOOKUP_EXCL) {
+       if (nd && (nd->flags & LOOKUP_EXCL)) {
                d_instantiate(direntry, NULL);
                return 0;