2013-01-04 08:23:09

by Xi Wang

[permalink] [raw]
Subject: [PATCH] nfs: fix null checking in nfs_get_option_str()

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 <[email protected]>
Cc: [email protected]
---
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)
--
1.7.10.4



2013-01-04 15:55:14

by Myklebust, Trond

[permalink] [raw]
Subject: Re: [PATCH] nfs: fix null checking in nfs_get_option_str()

On Fri, 2013-01-04 at 03:22 -0500, Xi Wang wrote:
+AD4- The following null pointer check is broken.
+AD4-
+AD4- +ACo-option +AD0- match+AF8-strdup(args)+ADs-
+AD4- return +ACE-option+ADs-
+AD4-
+AD4- The pointer +AGA-option' must be non-null, and thus +AGAAIQ-option' is always false.
+AD4- Use +AGAAIQAq-option' instead.
+AD4-
+AD4- The bug was introduced in commit c5cb09b6f8 (+ACI-Cleanup: Factor out some
+AD4- cut-and-paste code.+ACI-).
+AD4-
+AD4- Signed-off-by: Xi Wang +ADw-xi.wang+AEA-gmail.com+AD4-
+AD4- Cc: stable+AEA-vger.kernel.org
+AD4- ---
+AD4- fs/nfs/super.c +AHw- 2 +--
+AD4- 1 file changed, 1 insertion(+-), 1 deletion(-)
+AD4-
+AD4- diff --git a/fs/nfs/super.c b/fs/nfs/super.c
+AD4- index c25cadf8..2e7e8c8 100644
+AD4- --- a/fs/nfs/super.c
+AD4- +-+-+- b/fs/nfs/super.c
+AD4- +AEAAQA- -1152,7 +-1152,7 +AEAAQA- static int nfs+AF8-get+AF8-option+AF8-str(substring+AF8-t args+AFsAXQ-, char +ACoAKg-option)
+AD4- +AHs-
+AD4- kfree(+ACo-option)+ADs-
+AD4- +ACo-option +AD0- match+AF8-strdup(args)+ADs-
+AD4- - return +ACE-option+ADs-
+AD4- +- return +ACEAKg-option+ADs-
+AD4- +AH0-
+AD4-
+AD4- static int nfs+AF8-get+AF8-option+AF8-ul(substring+AF8-t args+AFsAXQ-, unsigned long +ACo-option)

Thank you+ACE- Applied to the bugfixes branch.

--
Trond Myklebust
Linux NFS client maintainer

NetApp
Trond.Myklebust+AEA-netapp.com
http://www.netapp.com