diff mbox

nfs: fix null checking in nfs_get_option_str()

Message ID 1357287777-12052-1-git-send-email-xi.wang@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Xi Wang Jan. 4, 2013, 8:22 a.m. UTC
The following null pointer check is broken.

	*option = match_strdup(args);
	return !option;

The pointer `option' must be non-null, and thus `!option' is always false.
Use `!*option' instead.

The bug was introduced in commit c5cb09b6f8 ("Cleanup: Factor out some
cut-and-paste code.").

Signed-off-by: Xi Wang <xi.wang@gmail.com>
Cc: stable@vger.kernel.org
---
 fs/nfs/super.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Trond Myklebust Jan. 4, 2013, 3:55 p.m. UTC | #1
On Fri, 2013-01-04 at 03:22 -0500, Xi Wang wrote:
> The following null pointer check is broken.
> 
> 	*option = match_strdup(args);
> 	return !option;
> 
> The pointer `option' must be non-null, and thus `!option' is always false.
> Use `!*option' instead.
> 
> The bug was introduced in commit c5cb09b6f8 ("Cleanup: Factor out some
> cut-and-paste code.").
> 
> Signed-off-by: Xi Wang <xi.wang@gmail.com>
> Cc: stable@vger.kernel.org
> ---
>  fs/nfs/super.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/nfs/super.c b/fs/nfs/super.c
> index c25cadf8..2e7e8c8 100644
> --- a/fs/nfs/super.c
> +++ b/fs/nfs/super.c
> @@ -1152,7 +1152,7 @@ static int nfs_get_option_str(substring_t args[], char **option)
>  {
>  	kfree(*option);
>  	*option = match_strdup(args);
> -	return !option;
> +	return !*option;
>  }
>  
>  static int nfs_get_option_ul(substring_t args[], unsigned long *option)

Thank you! Applied to the bugfixes branch.
diff mbox

Patch

diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index c25cadf8..2e7e8c8 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -1152,7 +1152,7 @@  static int nfs_get_option_str(substring_t args[], char **option)
 {
 	kfree(*option);
 	*option = match_strdup(args);
-	return !option;
+	return !*option;
 }
 
 static int nfs_get_option_ul(substring_t args[], unsigned long *option)