On Fri, Oct 06, 2023 at 10:03:33AM +0200, David Hildenbrand wrote: > > + * > > + * Returns number of pages pinned. This would be equal to the number of > > + * pages requested. > > + * If nr_pages is 0 or negative, returns 0. If no pages were pinned, returns > > + * -errno. > > + */ > > +long pin_user_pages_fd(int fd, pgoff_t start, unsigned long nr_pages, > > + unsigned int gup_flags, struct page **pages) > > +{ > > + struct page *page; > > + struct file *filep; > > + unsigned int flags, i; > > + long ret; > > + > > + if (nr_pages <= 0) > > + return 0; > > I think we should just forbid that and use a WARN_ON_ONCE() here / return > -EINVAL. So we'll never end up returning 0. Why is the check even needed? It looked like it just runs through normally and returns 0, that is fine.. Jason