Re: [PATCH] [suggestion] mm/gup: avoid IS_ERR_OR_NULL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, May 19, 2023 at 03:51:51PM +0100, Lorenzo Stoakes wrote:
> Given you are sharply criticising the code I authored here, is it too much
> to ask for you to cc- me, the author on commentaries like this? Thanks.
> 
> On Fri, May 19, 2023 at 11:39:13AM +0200, Arnd Bergmann wrote:
> > From: Arnd Bergmann <arnd@xxxxxxxx>
> >
> > While looking at an unused-variable warning, I noticed a new interface coming
> > in that requires the use of IS_ERR_OR_NULL(), which tends to indicate bad
> > interface design and is usually surprising to users.
> 
> I am not sure I understand your reasoning, why does it 'tend to indicate
> bad interface design'? You say that as if it is an obvious truth. Not
> obvious to me at all.
>
> There are 3 possible outcomes from the function - an error, the function
> failing to pin a page, or it succeeding in doing so. For some of the
> callers that results in an error, for others it is not an error.

No, there really isn't.

Either it pins the page or it doesn't. Returning "NULL" to mean a
specific kind of failure was encountered is crazy.. Especially if we
don't document what that specific failure even was.

IIRC if you look really closely the only time get_user_pages()
actually returns 0 is if the input argument validation fails, which I
think is a bug that should be fixed.

get_user_pages() never returns 0, so get_user_page_vma_remote() never
returns NULL. Until we get there collapsing the 0 to EIO is perfectly
fine.

Jason




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux