diff --git a/sys/sys/filedesc.h b/sys/sys/filedesc.h index bf416e91edff..41106f7bcd44 100644 --- a/sys/sys/filedesc.h +++ b/sys/sys/filedesc.h @@ -141,7 +141,7 @@ static __inline struct file * fget_locked(struct filedesc *fdp, int fd) { - return ((unsigned int)fd >= fdp->fd_nfiles ? NULL : fdp->fd_ofiles[fd]); + return (fd < 0 || fd >= fdp->fd_nfiles ? NULL : fdp->fd_ofiles[fd]); } #endif /* _KERNEL */