public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* NFS thinko
@ 2004-04-16 21:16 Dave Jones
  2004-04-16 21:32 ` Russell King
  2004-04-16 22:09 ` J. Bruce Fields
  0 siblings, 2 replies; 3+ messages in thread
From: Dave Jones @ 2004-04-16 21:16 UTC (permalink / raw)
  To: trond.myklebust; +Cc: Linux Kernel

Dereferencing 'exp' before the check for NULL.

		Dave


--- linux-2.6.5/include/linux/nfsd/export.h~	2004-04-16 22:13:28.000000000 +0100
+++ linux-2.6.5/include/linux/nfsd/export.h	2004-04-16 22:14:21.000000000 +0100
@@ -118,13 +118,15 @@
 	if (ek && !IS_ERR(ek)) {
 		struct svc_export *exp = ek->ek_export;
 		int err;
+		if (!exp)
+			goto out;
 		cache_get(&exp->h);
 		expkey_put(&ek->h, &svc_expkey_cache);
-		if (exp &&
-		    (err = cache_check(&svc_export_cache, &exp->h, reqp)))
+		if (err = cache_check(&svc_export_cache, &exp->h, reqp))
 			exp = ERR_PTR(err);
 		return exp;
 	} else
+out:
 		return ERR_PTR(PTR_ERR(ek));
 }
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: NFS thinko
  2004-04-16 21:16 NFS thinko Dave Jones
@ 2004-04-16 21:32 ` Russell King
  2004-04-16 22:09 ` J. Bruce Fields
  1 sibling, 0 replies; 3+ messages in thread
From: Russell King @ 2004-04-16 21:32 UTC (permalink / raw)
  To: Dave Jones, trond.myklebust, Linux Kernel

On Fri, Apr 16, 2004 at 10:16:28PM +0100, Dave Jones wrote:
> Dereferencing 'exp' before the check for NULL.

Hmm.  If we're referencing 'ek' to get at exp, 'ek' isn't an error,
so it shouldn't be passed into PTR_ERR().

> --- linux-2.6.5/include/linux/nfsd/export.h~	2004-04-16 22:13:28.000000000 +0100
> +++ linux-2.6.5/include/linux/nfsd/export.h	2004-04-16 22:14:21.000000000 +0100
> @@ -118,13 +118,15 @@
>  	if (ek && !IS_ERR(ek)) {
>  		struct svc_export *exp = ek->ek_export;
>  		int err;
> +		if (!exp)
> +			goto out;
>  		cache_get(&exp->h);
>  		expkey_put(&ek->h, &svc_expkey_cache);
> -		if (exp &&
> -		    (err = cache_check(&svc_export_cache, &exp->h, reqp)))
> +		if (err = cache_check(&svc_export_cache, &exp->h, reqp))
>  			exp = ERR_PTR(err);
>  		return exp;
>  	} else
> +out:
>  		return ERR_PTR(PTR_ERR(ek));
>  }

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 PCMCIA      - http://pcmcia.arm.linux.org.uk/
                 2.6 Serial core

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: NFS thinko
  2004-04-16 21:16 NFS thinko Dave Jones
  2004-04-16 21:32 ` Russell King
@ 2004-04-16 22:09 ` J. Bruce Fields
  1 sibling, 0 replies; 3+ messages in thread
From: J. Bruce Fields @ 2004-04-16 22:09 UTC (permalink / raw)
  To: Dave Jones, trond.myklebust, Linux Kernel

On Fri, Apr 16, 2004 at 10:16:28PM +0100, Dave Jones wrote:
> Dereferencing 'exp' before the check for NULL.

It would be a bug if exp were ever NULL there.  Better just to delete
that check entirely.

--Bruce Fields


If ek = exp_find_key() is not an error, then ek->ek_export should be
set; no point in checking if it's NULL.


 include/linux/nfsd/export.h |    3 +--
 1 files changed, 1 insertion(+), 2 deletions(-)

diff -puN include/linux/nfsd/export.h~export_exp_deref_fix include/linux/nfsd/export.h
--- linux-2.6.6-rc1/include/linux/nfsd/export.h~export_exp_deref_fix	2004-04-16 17:51:57.000000000 -0400
+++ linux-2.6.6-rc1-bfields/include/linux/nfsd/export.h	2004-04-16 17:58:30.000000000 -0400
@@ -120,8 +120,7 @@ exp_find(struct auth_domain *clp, int fs
 		int err;
 		cache_get(&exp->h);
 		expkey_put(&ek->h, &svc_expkey_cache);
-		if (exp &&
-		    (err = cache_check(&svc_export_cache, &exp->h, reqp)))
+		if ((err = cache_check(&svc_export_cache, &exp->h, reqp)))
 			exp = ERR_PTR(err);
 		return exp;
 	} else

_

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-04-16 22:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-16 21:16 NFS thinko Dave Jones
2004-04-16 21:32 ` Russell King
2004-04-16 22:09 ` J. Bruce Fields

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox