Commit 58939473bacf08e7e7346673c6d70bc367bd091a

Authored by Tony Battersby
Committed by Linus Torvalds
1 parent 5a19ae4bb0

vfs: improve comment describing fget_light()

Improve the description of fget_light(), which is currently incorrect
about needing a prior refcnt (judging by the way it is actually used).

Signed-off-by: Tony Battersby <tonyb@cybernetics.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 14 additions and 5 deletions Side-by-side Diff

... ... @@ -298,11 +298,20 @@
298 298 EXPORT_SYMBOL(fget);
299 299  
300 300 /*
301   - * Lightweight file lookup - no refcnt increment if fd table isn't shared.
302   - * You can use this only if it is guranteed that the current task already
303   - * holds a refcnt to that file. That check has to be done at fget() only
304   - * and a flag is returned to be passed to the corresponding fput_light().
305   - * There must not be a cloning between an fget_light/fput_light pair.
  301 + * Lightweight file lookup - no refcnt increment if fd table isn't shared.
  302 + *
  303 + * You can use this instead of fget if you satisfy all of the following
  304 + * conditions:
  305 + * 1) You must call fput_light before exiting the syscall and returning control
  306 + * to userspace (i.e. you cannot remember the returned struct file * after
  307 + * returning to userspace).
  308 + * 2) You must not call filp_close on the returned struct file * in between
  309 + * calls to fget_light and fput_light.
  310 + * 3) You must not clone the current task in between the calls to fget_light
  311 + * and fput_light.
  312 + *
  313 + * The fput_needed flag returned by fget_light should be passed to the
  314 + * corresponding fput_light.
306 315 */
307 316 struct file *fget_light(unsigned int fd, int *fput_needed)
308 317 {