Linux CIFS filesystem development
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Sean Finney <seanius-ADwgVSpYHhHR7s880joybQ@public.gmane.org>
Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v4 5/6] cifs: Use kstrndup for cifs_sb->mountdata
Date: Fri, 8 Apr 2011 09:53:33 -0400	[thread overview]
Message-ID: <20110408095333.2dab9301@corrin.poochiereds.net> (raw)
In-Reply-To: <1302100005-1848-5-git-send-email-seanius-ADwgVSpYHhHR7s880joybQ@public.gmane.org>

On Wed, 6 Apr 2011 16:26:44 +0200
Sean Finney <seanius-ADwgVSpYHhHR7s880joybQ@public.gmane.org> wrote:

> A relatively minor nit, but also clarified the "consensus" from the
> preceding comments that it is in fact better to try for the kstrdup
> early and cleanup while cleaning up is still a simple thing to do.
> 
> Reviewed-By: Steve French <smfrench-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Sean Finney <seanius-ADwgVSpYHhHR7s880joybQ@public.gmane.org>
> ---
>  fs/cifs/cifsfs.c |   18 +++++++-----------
>  1 files changed, 7 insertions(+), 11 deletions(-)
> 
> diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
> index fb6a2ad..cf8a610 100644
> --- a/fs/cifs/cifsfs.c
> +++ b/fs/cifs/cifsfs.c
> @@ -134,24 +134,20 @@ cifs_read_super(struct super_block *sb, void *data,
>  	cifs_sb->bdi.ra_pages = default_backing_dev_info.ra_pages;
>  
>  #ifdef CONFIG_CIFS_DFS_UPCALL
> -	/* copy mount params to sb for use in submounts */
> -	/* BB: should we move this after the mount so we
> -	 * do not have to do the copy on failed mounts?
> -	 * BB: May be it is better to do simple copy before
> -	 * complex operation (mount), and in case of fail
> -	 * just exit instead of doing mount and attempting
> -	 * undo it if this copy fails?*/
> +	/*
> +	 * Copy mount params to sb for use in submounts. Better to do
> +	 * the copy here and deal with the error before cleanup gets
> +	 * complicated post-mount.
> +	 */
>  	if (data) {
> -		int len = strlen(data);
> -		cifs_sb->mountdata = kzalloc(len + 1, GFP_KERNEL);
> +		cifs_sb->mountdata = kstrndup(data, PAGE_CACHE_SIZE,
> +					      GFP_KERNEL);
>  		if (cifs_sb->mountdata == NULL) {
>  			bdi_destroy(&cifs_sb->bdi);
>  			kfree(sb->s_fs_info);
>  			sb->s_fs_info = NULL;
>  			return -ENOMEM;
>  		}
> -		strncpy(cifs_sb->mountdata, data, len + 1);
> -		cifs_sb->mountdata[len] = '\0';
>  	}
>  #endif
>  

I was wrong before, and we should be using PAGE_SIZE here instead of
PAGE_CACHE_SIZE. On all arches that I know of those are equivalent
currently, but that might not be the case in the future. It might not
hurt to change that in these patches though if you're respinning them
anyway.

Either way, you can add my:

Reviewed-by: Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

  parent reply	other threads:[~2011-04-08 13:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-06 14:26 [PATCH v4 1/6] cifs: Extract DFS referral expansion logic to separate function Sean Finney
     [not found] ` <1302100005-1848-1-git-send-email-seanius-ADwgVSpYHhHR7s880joybQ@public.gmane.org>
2011-04-06 14:26   ` [PATCH v4 2/6] cifs: Add support for mounting Windows 2008 DFS shares Sean Finney
     [not found]     ` <1302100005-1848-2-git-send-email-seanius-ADwgVSpYHhHR7s880joybQ@public.gmane.org>
2011-04-07 13:33       ` Jeff Layton
2011-04-06 14:26   ` [PATCH v4 3/6] cifs: cifs_parse_mount_options: do not tokenize mount options in-place Sean Finney
     [not found]     ` <1302100005-1848-3-git-send-email-seanius-ADwgVSpYHhHR7s880joybQ@public.gmane.org>
2011-04-08 13:48       ` Jeff Layton
2011-04-06 14:26   ` [PATCH v4 4/6] cifs: Simplify handling of submount options in cifs_mount Sean Finney
     [not found]     ` <1302100005-1848-4-git-send-email-seanius-ADwgVSpYHhHR7s880joybQ@public.gmane.org>
2011-04-08 13:50       ` Jeff Layton
2011-04-06 14:26   ` [PATCH v4 5/6] cifs: Use kstrndup for cifs_sb->mountdata Sean Finney
     [not found]     ` <1302100005-1848-5-git-send-email-seanius-ADwgVSpYHhHR7s880joybQ@public.gmane.org>
2011-04-08 13:53       ` Jeff Layton [this message]
     [not found]         ` <20110408095333.2dab9301-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
2011-04-08 14:28           ` Sean Finney
2011-04-06 14:26   ` [PATCH v4 6/6] cifs: Unconditionally copy mount options to superblock info Sean Finney
     [not found]     ` <1302100005-1848-6-git-send-email-seanius-ADwgVSpYHhHR7s880joybQ@public.gmane.org>
2011-04-08 13:54       ` Jeff Layton
2011-04-26  5:43   ` [PATCH v4 1/6] cifs: Extract DFS referral expansion logic to separate function Suresh Jayaraman
     [not found]     ` <4DB65B74.7050706-l3A5Bk7waGM@public.gmane.org>
2011-04-26 11:40       ` Sean Finney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110408095333.2dab9301@corrin.poochiereds.net \
    --to=jlayton-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=seanius-ADwgVSpYHhHR7s880joybQ@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox