From 7a4981c1f624b00f2e140f62036a581a66148172 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Thu, 14 Jun 2012 16:24:03 +0000 Subject: [PATCH] Explicitly assert that the filedesc lock is held when the fget_locked() function is called. MFC after: 1 month --- sys/sys/filedesc.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sys/sys/filedesc.h b/sys/sys/filedesc.h index 2be03af64c75..855d2b3bb0c9 100644 --- a/sys/sys/filedesc.h +++ b/sys/sys/filedesc.h @@ -142,7 +142,12 @@ static __inline struct file * fget_locked(struct filedesc *fdp, int fd) { - return (fd < 0 || fd >= fdp->fd_nfiles ? NULL : fdp->fd_ofiles[fd]); + FILEDESC_LOCK_ASSERT(fdp); + + if (fd < 0 || fd >= fdp->fd_nfiles) + return (NULL); + + return (fdp->fd_ofiles[fd]); } #endif /* _KERNEL */