Fix issues reported by coverity in include/linux/nfsd/nfsfh.h
Subsystems (2)
This patch tries to fix two minor issues reported in include/linux/nfsd/nfsfh.h by Coverity, please review and apply if correct.
Errors reported:
CID: 3589
Checker: FORWARD_NULL
File: include/linux/nfsd/nfsfh.h
Function: fh_unlock
Description: Variable "(fhp)->fh_dentry" tracked as NULL was dereferenced.
CID: 2657
Checker: FORWARD_NULL
File: include/linux/nfsd/nfsfh.h
Function: fh_copy
Description: Variable "dentry" tracked as NULL was dereferenced.
Patch Description:
1. In fh_copy, the check "src->fh_dentry || src->fh_locked" does not seem to make sense. If "fh_dentry" is NULL and fh_locked is set (which should not happen), we should not dereference fh_dentry and panic.
2. In fh_unlock, return after reporting error if fh_dentry == NULL, this will be consistent with the other places where fh_dentry is checked.
---
nfsfh.h | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-)
include/linux/nfsd/nfsfh.h +6 -2
@@ -218,11 +218,13 @@static __inline__struct svc_fh *fh_copy (struct svc_fh *dst,struct svc_fh *src) { -if (src->fh_dentry || src->fh_locked) { +if (src->fh_dentry) {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); } +if (src->fh_locked) +printk (KERN_ERR "fh_copy: already locked!\n" ); *dst = *src;return dst;
@@ -328,8 +330,10 @@static inline void fh_unlock (struct svc_fh *fhp) { -if (!fhp->fh_dentry) +if (!fhp->fh_dentry) {printk (KERN_ERR "fh_unlock: fh not verified!\n" ); +return ; + }if (fhp->fh_locked) {fill_post_wcc (fhp);
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
Quoted 39 lines · Jayachandran C.
This patch tries to fix two minor issues reported in
include/linux/nfsd/nfsfh.hby Coverity, please review and apply if correct.Errors reported:
CID: 3589
Checker:FORWARD_NULL
File:include/linux/nfsd/nfsfh.h
Function:fh_unlock
Description: Variable "(fhp)->fh_dentry" tracked as NULL was dereferenced.CID: 2657
Checker:FORWARD_NULL
File:include/linux/nfsd/nfsfh.h
Function:fh_copy
Description: Variable "dentry" tracked as NULL was dereferenced.Patch Description:
1. Infh_copy, the check "src->fh_dentry||src->fh_locked" does not seem to make sense. If "fh_dentry" is NULL andfh_lockedis set (which should not happen), we should not dereferencefh_dentryand panic.2. In
fh_unlock, return after reporting error iffh_dentry== NULL, this will be consistent with the other places wherefh_dentryis checked.Signed-off-by Jayachandran C. <c.jayachandran at gmail.com>---
nfsfh.h | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-)diff -ur
linux-2.6.15-rc3-git1.clean/include/linux/nfsd/nfsfh.hlinux-2.6.15-rc3-git1/include/linux/nfsd/nfsfh.hinclude/linux/nfsd/nfsfh.h +0
-0@@ -218,11 +218,13 @@ static __inline__ struct svc_fh *
include/linux/nfsd/nfsfh.h line 227
Quoted 10 lines
include/linux/nfsd/nfsfh.h +3
-1fh_copy(struct svc_fh *dst, struct svc_fh *src) { -if (src->fh_dentry || src->fh_locked) { +if (src->fh_dentry) {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); } +if (src->fh_locked) +printk (KERN_ERR "fh_copy: already locked!\n" );
How useful are these printks anyway? Can't we convert them into BUG_ON or WARN_ONs? To me it looks like they are signalling an implementation bug in which case we should also be generating a stack dump in order to figure out how to fix the bug.
If, OTOH, they are signalling some weird behaviour that is allowed, but might be useful to track when debugging, then we should really convert them into dprintks so that we don't risk spamming the syslog in production systems.
Cheers,
Trond
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
Quoted 3 lines · Trond Myklebust
Quoted 2 lines · Jayachandran C.
This patch tries to fix two minor issues reported in
include/linux/nfsd/nfsfh.hby Coverity, please review and apply if correct.
[...]
Quoted 22 lines
Quoted 6 lines
diff -ur
linux-2.6.15-rc3-git1.clean/include/linux/nfsd/nfsfh.hlinux-2.6.15-rc3-git1/include/linux/nfsd/nfsfh.hinclude/linux/nfsd/nfsfh.h +0
-0@@ -218,11 +218,13 @@ static __inline__ struct svc_fh *include/linux/nfsd/nfsfh.h line 227
Quoted 10 lines
include/linux/nfsd/nfsfh.h +3
-1fh_copy(struct svc_fh *dst, struct svc_fh *src) { -if (src->fh_dentry || src->fh_locked) { +if (src->fh_dentry) {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); } +if (src->fh_locked) +printk (KERN_ERR "fh_copy: already locked!\n" );How useful are these printks anyway? Can't we convert them into
BUG_ONorWARN_ONs? To me it looks like they are signalling an implementation bug in which case we should also be generating a stack dump in order to figure out how to fix the bug.
Quoted 4 lines
If, OTOH, they are signalling some weird behaviour that is allowed, but might be useful to track when debugging, then we should really convert them into dprintks so that we don't risk spamming the syslog in production systems.
Yes, these probably should be dprintk or BUG/WARN messages, but it would be a more fundamental change to convert the whole NFSD code to that style of error reporting.
This patch just fixes a couple of places to avoid null dereference in case of error.
Regards,
JC.
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs