Skip to contentSkip to conversation

nfsd: fix comparison in fh_fsid_match()

PATCH In review Dan Carpenter 3 participants 4 messages Feb 11, 2015 – Feb 12, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nfsd: fix comparison in fh_fsid_match()

We're supposed to be testing that the fh_fsid's match but because the parenthesis are in the wrong place, then we only check the first byte.

Fixes 9558f2500a20 ('nfsd: add fh_fsid_match helper')
fs/nfsd/nfsfh.h +1 -1
index 84cae20..f229204 100644
@@ -200,7 +200,7 @@ static inline bool fh_fsid_match(struct knfsd_fh *fh1, struct knfsd_fh *fh2)
 {
 	if (fh1->fh_fsid_type != fh2->fh_fsid_type)
 		return false;
-	if (memcmp(fh1->fh_fsid, fh2->fh_fsid, key_len(fh1->fh_fsid_type) != 0))
+	if (memcmp(fh1->fh_fsid, fh2->fh_fsid, key_len(fh1->fh_fsid_type)) != 0)
 		return false;
 	return true;
 }
#1 lore raw
Quoted 5 lines · Dan Carpenter

We're supposed to be testing that the fh_fsid's match but because the parenthesis are in the wrong place, then we only check the first byte.

Fixes 9558f2500a20 ('nfsd: add fh_fsid_match helper')

Thanks, this looks good. Is there an easy to setup way to check for these sorts of errors?

#2 lore raw
Quoted 9 lines · Christoph Hellwig
Quoted 5 lines · Dan Carpenter

We're supposed to be testing that the fh_fsid's match but because the parenthesis are in the wrong place, then we only check the first byte.

Fixes 9558f2500a20 ('nfsd: add fh_fsid_match helper')

Thanks, this looks good. Is there an easy to setup way to check for these sorts of errors?

This is a Smatch check I wrote a couple years ago but it never found any bugs until now so I didn't commit it. I have done. I'll push it out later and Fengguang will eventually add it to the zero day tester bot.

regards,
dan carpenter

#3 lore raw
In reply to Dan Carpenter
Quoted 3 lines · Dan Carpenter

We're supposed to be testing that the fh_fsid's match but because the parenthesis are in the wrong place, then we only check the first byte.

Thanks, I'll pass this along!

--b.

Quoted 17 lines
Fixes 9558f2500a20 ('nfsd: add fh_fsid_match helper')
fs/nfsd/nfsfh.h +1 -1
index 84cae20..f229204 100644
@@ -200,7 +200,7 @@ static inline bool fh_fsid_match(struct knfsd_fh *fh1, struct knfsd_fh *fh2)
 {
 	if (fh1->fh_fsid_type != fh2->fh_fsid_type)
 		return false;
-	if (memcmp(fh1->fh_fsid, fh2->fh_fsid, key_len(fh1->fh_fsid_type) != 0))
+	if (memcmp(fh1->fh_fsid, fh2->fh_fsid, key_len(fh1->fh_fsid_type)) != 0)
 		return false;
 	return true;
 }