• Eric Biggers's avatar
    fs/pipe.c: preserve alloc_file() error code · e9bb1f9b
    Eric Biggers authored
    If sys_pipe() was unable to allocate a 'struct file', it always failed
    with ENFILE, which means "The number of simultaneously open files in the
    system would exceed a system-imposed limit." However, alloc_file()
    actually returns an ERR_PTR value and might fail with other error codes.
    Currently, in addition to ENFILE, it can fail with ENOMEM, potentially
    when there are few open files in the system.  Update sys_pipe() to
    preserve this error code.
    
    In a prior submission of a similar patch (1) some concern was raised
    about introducing a new error code for sys_pipe().  However, for most
    system calls, programs cannot assume that new error codes will never be
    introduced.  In addition, ENOMEM was, in fact, already a possible error
    code for sys_pipe(), in the case where the file descriptor table could
    not be expanded due to insufficient memory.
    
    	(1) http://comments.gmane.org/gmane.linux.kernel/1357942Signed-off-by: default avatarEric Biggers <ebiggers3@gmail.com>
    Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
    e9bb1f9b
pipe.c 25 KB