include/linux/nfsd/nfsfh.h: fix a NULL
Subsystems (2)
RFC PATCH 1/1 include/linux/nfsd/nfsfh.h: fix a NULL
dereference
Reply-To:
Fcc: =sent-mail
When we know fhp->fh_dentry is NULL, a code path where it's being dereferenced isn't a good choice.
Spotted by the coverity checker.
include/linux/nfsd/nfsfh.h renamed from include/linux/nfsd/nfsfh.h.old +1 -2
@@ -330,8 +330,7 @@ fh_unlock(struct svc_fh *fhp) {if (!fhp->fh_dentry)printk (KERN_ERR "fh_unlock: fh not verified!\n" ); - -if (fhp->fh_locked) { +else if (fhp->fh_locked) {fill_post_wcc (fhp);mutex_unlock (&fhp->fh_dentry->d_inode->i_mutex); fhp->fh_locked =0 ;
Quoted 15 lines · Adrian Bunk
dereference
Reply-To:
Fcc: =sent-mailWhen we know
fhp->fh_dentryis NULL, a code path where it's being dereferenced isn't a good choice.Spotted by the coverity checker.
Signed-off-by Adrian Bunk <[email protected]>
include/linux/nfsd/nfsfh.h fh_unlock(struct svc_fh *fhp) · line 336
Quoted 9 lines
include/linux/nfsd/nfsfh.h renamed from include/linux/nfsd/nfsfh.h.old +1
-2@@ -330,8 +330,7 @@ fh_unlock(struct svc_fh *fhp) {if (!fhp->fh_dentry)printk (KERN_ERR "fh_unlock: fh not verified!\n" ); - -if (fhp->fh_locked) { +else if (fhp->fh_locked) {fill_post_wcc (fhp);mutex_unlock (&fhp->fh_dentry->d_inode->i_mutex); fhp->fh_locked =0 ;
This issue has come up on lkml before. Please just convert that check for fhp->fh_dentry into a BUG_ON().
Trond
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 include/linux/nfsd/nfsfh.h:fh_unlock(): change an error to a BUG_ON()
Quoted 12 lines · Trond Myklebust
Quoted 11 lines · Adrian Bunk
dereference
Reply-To:
Fcc: =sent-mailWhen we know
fhp->fh_dentryis NULL, a code path where it's being dereferenced isn't a good choice.Spotted by the coverity checker.
Signed-off-by Adrian Bunk <[email protected]>
Quoted 16 lines
include/linux/nfsd/nfsfh.h fh_unlock(struct svc_fh *fhp) · line 336
Quoted 13 lines
include/linux/nfsd/nfsfh.h renamed from include/linux/nfsd/nfsfh.h.old +1
-2@@ -330,8 +330,7 @@ fh_unlock(struct svc_fh *fhp) {if (!fhp->fh_dentry)printk (KERN_ERR "fh_unlock: fh not verified!\n" ); - -if (fhp->fh_locked) { +else if (fhp->fh_locked) {fill_post_wcc (fhp);mutex_unlock (&fhp->fh_dentry->d_inode->i_mutex); fhp->fh_locked =0 ;This issue has come up on lkml before. Please just convert that check for
fhp->fh_dentryinto aBUG_ON().
Patch below.
Quoted 1 line
Trond
cu
Adrian
<-- snip -->
!fhp->fh_dentry is a condition that mustn't ever happen (and we might run into additional trouble later).
include/linux/nfsd/nfsfh.h renamed from include/linux/nfsd/nfsfh.h.old +1 -2
@@ -328,8 +328,7 @@static inline void fh_unlock (struct svc_fh *fhp) { -if (!fhp->fh_dentry) -printk (KERN_ERR "fh_unlock: fh not verified!\n" ); +BUG_ON (!fhp->fh_dentry);if (fhp->fh_locked) {fill_post_wcc (fhp);
Re: [2.6 patch] include/linux/nfsd/nfsfh.h:fh_unlock(): change an error to a BUG_ON()
Quoted 6 lines · On Sunday November 12, [email protected] wrote:
Quoted 3 lines
This issue has come up on lkml before. Please just convert that check for
fhp->fh_dentryinto aBUG_ON().Patch below.
Thanks. I might that the opportunity to do a bit more cleaning up here and suggest this version .
NeilBrown
---------------------------
Subject: Replace some warning ins nfsfh.h with BUG_ON or WARN_ON
A couple of the warning will be followed by an Oops if they ever fire, so may as well be BUG_ON. Another isn't obviously fatal but has never been known to fire, so make it a WARN_ON.
### Diffstat output
./include/linux/nfsd/nfsfh.h | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
include/linux/nfsd/nfsfh.h +4 -11
@@ -217,11 +217,7 @@ void fh_put(struct svc_fh *);static __inline__struct svc_fh *fh_copy (struct svc_fh *dst,struct svc_fh *src) { -if (src->fh_dentry || src->fh_locked) { -struct dentry *dentry = src->fh_dentry; -printk (KERN_ERR "fh_copy: copying %s/%s, already verified!\n" , - dentry->d_parent->d_name.name, dentry->d_name.name); - } +WARN_ON (src->fh_dentry || src->fh_locked); *dst = *src;return dst;
@@ -300,10 +296,8 @@ fh_lock_nested(struct svc_fh *fhp, unsigdfprintk (FILEOP ,"nfsd: fh_lock(%s) locked = %d\n" ,SVCFH_fmt (fhp), fhp->fh_locked); -if (!fhp->fh_dentry) { -printk (KERN_ERR "fh_lock: fh not verified!\n" ); -return ; - } +BUG_ON (!dentry); +if (fhp->fh_locked) {printk (KERN_WARNING "fh_lock: %s/%s already locked!\n" , dentry->d_parent->d_name.name, dentry->d_name.name);
@@ -328,8 +322,7 @@ fh_lock(struct svc_fh *fhp)static inline void fh_unlock (struct svc_fh *fhp) { -if (!fhp->fh_dentry) -printk (KERN_ERR "fh_unlock: fh not verified!\n" ); +BUG_ON (!fhp->fh_dentry);if (fhp->fh_locked) {fill_post_wcc (fhp);