Patchwork cifs: propagate cifs_new_fileinfo() error back to the caller

login
register
mail settings
Submitter Suresh Jayaraman
Date May 11, 2010, 4:16 a.m.
Message ID <1273551406-7544-1-git-send-email-sjayaraman@suse.de>
Download mbox | patch
Permalink /patch/52277/
State New
Headers show

Comments

Suresh Jayaraman - May 11, 2010, 4:16 a.m.
..otherwise memory allocation errors go undetected.

Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de>
---
 fs/cifs/dir.c |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)
Shirish Pargaonkar - May 11, 2010, 1:23 p.m.
On Mon, May 10, 2010 at 11:16 PM, Suresh Jayaraman <sjayaraman@suse.de> wrote:
> ..otherwise memory allocation errors go undetected.
>
> Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de>
> ---
>  fs/cifs/dir.c |   17 +++++++++++++----
>  1 files changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
> index bd363df..86d3c0c 100644
> --- a/fs/cifs/dir.c
> +++ b/fs/cifs/dir.c
> @@ -261,8 +261,14 @@ int cifs_posix_open(char *full_path, struct inode **pinode,
>         * cifs_fill_filedata() takes care of setting cifsFileInfo pointer to
>         * file->private_data.
>         */
> -       if (mnt)
> -               cifs_new_fileinfo(*pinode, *pnetfid, NULL, mnt, oflags);
> +       if (mnt) {
> +               struct cifsFileInfo *pfile_info;
> +
> +               pfile_info = cifs_new_fileinfo(*pinode, *pnetfid, NULL, mnt,
> +                                              oflags);
> +               if (pfile_info == NULL)
> +                       rc = -ENOMEM;
> +       }
>
>  posix_open_ret:
>        kfree(presp_data);
> @@ -476,12 +482,15 @@ cifs_create_set_dentry:
>                /* mknod case - do not leave file open */
>                CIFSSMBClose(xid, tcon, fileHandle);
>        } else if (!(posix_create) && (newinode)) {
> +               struct cifsFileInfo *pfile_info;
>                /*
>                 * cifs_fill_filedata() takes care of setting cifsFileInfo
>                 * pointer to file->private_data.
>                 */
> -               cifs_new_fileinfo(newinode, fileHandle, NULL, nd->path.mnt,
> -                                 oflags);
> +               pfile_info = cifs_new_fileinfo(newinode, fileHandle, NULL,
> +                                              nd->path.mnt, oflags);
> +               if (pfile_info == NULL)
> +                       rc = -ENOMEM;
>        }
>  cifs_create_out:
>        kfree(buf);
> --
> 1.6.4.2
>
> _______________________________________________
> linux-cifs-client mailing list
> linux-cifs-client@lists.samba.org
> https://lists.samba.org/mailman/listinfo/linux-cifs-client
>

Acked-by: Shirish S. Pargaonkar <shirishpargaonkar@gmail.com>
Shirish Pargaonkar - May 11, 2010, 3:44 p.m.
On Mon, May 10, 2010 at 11:16 PM, Suresh Jayaraman <sjayaraman@suse.de> wrote:
> ..otherwise memory allocation errors go undetected.
>
> Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de>
> ---
>  fs/cifs/dir.c |   17 +++++++++++++----
>  1 files changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
> index bd363df..86d3c0c 100644
> --- a/fs/cifs/dir.c
> +++ b/fs/cifs/dir.c
> @@ -261,8 +261,14 @@ int cifs_posix_open(char *full_path, struct inode **pinode,
>         * cifs_fill_filedata() takes care of setting cifsFileInfo pointer to
>         * file->private_data.
>         */
> -       if (mnt)
> -               cifs_new_fileinfo(*pinode, *pnetfid, NULL, mnt, oflags);
> +       if (mnt) {
> +               struct cifsFileInfo *pfile_info;
> +
> +               pfile_info = cifs_new_fileinfo(*pinode, *pnetfid, NULL, mnt,
> +                                              oflags);
> +               if (pfile_info == NULL)
> +                       rc = -ENOMEM;
> +       }
>
>  posix_open_ret:
>        kfree(presp_data);
> @@ -476,12 +482,15 @@ cifs_create_set_dentry:
>                /* mknod case - do not leave file open */
>                CIFSSMBClose(xid, tcon, fileHandle);
>        } else if (!(posix_create) && (newinode)) {
> +               struct cifsFileInfo *pfile_info;
>                /*
>                 * cifs_fill_filedata() takes care of setting cifsFileInfo
>                 * pointer to file->private_data.
>                 */
> -               cifs_new_fileinfo(newinode, fileHandle, NULL, nd->path.mnt,
> -                                 oflags);
> +               pfile_info = cifs_new_fileinfo(newinode, fileHandle, NULL,
> +                                              nd->path.mnt, oflags);
> +               if (pfile_info == NULL)
> +                       rc = -ENOMEM;
>        }
>  cifs_create_out:
>        kfree(buf);
> --
> 1.6.4.2
>
> _______________________________________________
> linux-cifs-client mailing list
> linux-cifs-client@lists.samba.org
> https://lists.samba.org/mailman/listinfo/linux-cifs-client
>

Reviewed-by: Shirish S. Pargaonkar <shirishpargaonkar@gmail.com>

Patch

diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index bd363df..86d3c0c 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -261,8 +261,14 @@  int cifs_posix_open(char *full_path, struct inode **pinode,
 	 * cifs_fill_filedata() takes care of setting cifsFileInfo pointer to
 	 * file->private_data.
 	 */
-	if (mnt)
-		cifs_new_fileinfo(*pinode, *pnetfid, NULL, mnt, oflags);
+	if (mnt) {
+		struct cifsFileInfo *pfile_info;
+
+		pfile_info = cifs_new_fileinfo(*pinode, *pnetfid, NULL, mnt,
+					       oflags);
+		if (pfile_info == NULL)
+			rc = -ENOMEM;
+	}
 
 posix_open_ret:
 	kfree(presp_data);
@@ -476,12 +482,15 @@  cifs_create_set_dentry:
 		/* mknod case - do not leave file open */
 		CIFSSMBClose(xid, tcon, fileHandle);
 	} else if (!(posix_create) && (newinode)) {
+		struct cifsFileInfo *pfile_info;
 		/*
 		 * cifs_fill_filedata() takes care of setting cifsFileInfo
 		 * pointer to file->private_data.
 		 */
-		cifs_new_fileinfo(newinode, fileHandle, NULL, nd->path.mnt,
-				  oflags);
+		pfile_info = cifs_new_fileinfo(newinode, fileHandle, NULL,
+					       nd->path.mnt, oflags);
+		if (pfile_info == NULL)
+			rc = -ENOMEM;
 	}
 cifs_create_out:
 	kfree(buf);