pipe()/pipe2() system calls may fail now with ENOMEM error during creation in
pipe_create() -> pipespace(). The bellow diff replaces ENOMEM with ENFILE
errno which is already documented for pipe()/pipe2() to decrease amount of
possible errno(s) with similar behaviour.

Index: sys_pipe.c
===================================================================
RCS file: /cvs/src/sys/kern/sys_pipe.c,v
retrieving revision 1.76
diff -u -p -r1.76 sys_pipe.c
--- sys_pipe.c  11 Feb 2017 19:51:06 -0000      1.76
+++ sys_pipe.c  18 Dec 2017 19:19:47 -0000
@@ -198,7 +198,7 @@ free1:
  * Allocate kva for pipe circular buffer, the space is pageable.
  * This routine will 'realloc' the size of a pipe safely, if it fails
  * it will retain the old buffer.
- * If it fails it will return ENOMEM.
+ * If it fails it will return ENFILE.
  */
 int
 pipespace(struct pipe *cpipe, u_int size)
@@ -207,7 +207,7 @@ pipespace(struct pipe *cpipe, u_int size

        buffer = km_alloc(size, &kv_any, &kp_pageable, &kd_waitok);
        if (buffer == NULL) {
-               return (ENOMEM);
+               return (ENFILE);
        }

        /* free old resources if we are resizing */

Reply via email to