diff options
author | Jim Rees <rees@umich.edu> | 2013-05-17 17:33:00 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2013-05-21 11:02:03 -0400 |
commit | 1a9357f443d64aa41e9b0dc414953663a6fcca19 (patch) | |
tree | 590818d77f07ab18197167024779738ec2a01f12 /fs | |
parent | b6040f9706c4c81cc50b50855ed70840f022bebb (diff) |
nfsd: avoid undefined signed overflow
In C, signed integer overflow results in undefined behavior, but unsigned
overflow wraps around. So do the subtraction first, then cast to signed.
Reported-by: Joakim Tjernlund <joakim.tjernlund@transmode.se>
Signed-off-by: Jim Rees <rees@umich.edu>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfsd/nfs4state.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 91ead0ed9f11..72f0c4e9a942 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -3427,7 +3427,7 @@ grace_disallows_io(struct net *net, struct inode *inode) | |||
3427 | /* Returns true iff a is later than b: */ | 3427 | /* Returns true iff a is later than b: */ |
3428 | static bool stateid_generation_after(stateid_t *a, stateid_t *b) | 3428 | static bool stateid_generation_after(stateid_t *a, stateid_t *b) |
3429 | { | 3429 | { |
3430 | return (s32)a->si_generation - (s32)b->si_generation > 0; | 3430 | return (s32)(a->si_generation - b->si_generation) > 0; |
3431 | } | 3431 | } |
3432 | 3432 | ||
3433 | static __be32 check_stateid_generation(stateid_t *in, stateid_t *ref, bool has_session) | 3433 | static __be32 check_stateid_generation(stateid_t *in, stateid_t *ref, bool has_session) |