Skip to content

Commit d0e71e2

Browse files
committed
Revert "fanotify: remove unneeded sub-zero check for unsigned value"
This reverts commit e659522. These kinds of patches are only making the code worse. Compilers don't care about the unnecessary check, but removing it makes the code less obvious to a human. The declaration of 'len' is more than 80 lines earlier, so a human won't easily see that 'len' is of an unsigned type, so to a human the range check that checks against zero is much more explicit and obvious. Any tool that complains about a range check like this just because the variable is unsigned is actively detrimental, and should be ignored. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 5af9d1c commit d0e71e2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/notify/fanotify/fanotify_user.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ static int copy_fid_info_to_user(__kernel_fsid_t *fsid, struct fanotify_fh *fh,
502502
}
503503

504504
/* Pad with 0's */
505-
WARN_ON_ONCE(len >= FANOTIFY_EVENT_ALIGN);
505+
WARN_ON_ONCE(len < 0 || len >= FANOTIFY_EVENT_ALIGN);
506506
if (len > 0 && clear_user(buf, len))
507507
return -EFAULT;
508508

0 commit comments

Comments
 (0)