NetBSD Problem Report #45423

From woods@once.weird.com  Tue Oct  4 18:45:21 2011
Return-Path: <woods@once.weird.com>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 6E95563B85F
	for <gnats-bugs@gnats.NetBSD.org>; Tue,  4 Oct 2011 18:45:21 +0000 (UTC)
Message-Id: <m1RB9zR-001EBeC@once.weird.com>
Date: Tue, 4 Oct 2011 11:45:17 -0700 (PDT)
From: "Greg A. Woods" <woods@planix.com>
Sender: "Greg A. Woods" <woods@once.weird.com>
Reply-To: "Greg A. Woods" <woods@planix.com>
To: gnats-bugs@gnats.NetBSD.org
Subject: the actual error from pipe_create() should be used instead of being rewritten
X-Send-Pr-Version: 3.95

>Number:         45423
>Category:       kern
>Synopsis:       the actual error from pipe_create() should be used instead of being rewritten
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Oct 04 18:50:00 +0000 2011
>Closed-Date:    Wed Oct 05 13:56:07 +0000 2011
>Last-Modified:  Wed Oct 05 13:56:07 +0000 2011
>Originator:     Greg A. Woods
>Release:        NetBSD-current 2011/10/04
>Organization:
Planix, Inc.; Kelowna, BC; Canada
>Environment:
System: NetBSD
Architecture: all
Machine: all
>Description:

	One should use the actual error result from an internal helper
	function that carefully returns proper error codes instead of
	rewriting any error to some (other) hard-coded value.

	In this case there is currently only one possible error that can
	be returned by pipe_create() and it matches what is returned by
	its caller, but I think it's important not to unilaterally
	ignore future possible errors by unilaterally rewriting the
	error

>How-To-Repeat:

>Fix:

Index: sys/kern/sys_pipe.c
===================================================================
RCS file: /cvs/master/m-NetBSD/main/src/sys/kern/sys_pipe.c,v
retrieving revision 1.132
diff -u -r1.132 sys_pipe.c
--- sys/kern/sys_pipe.c	15 Jul 2011 14:50:19 -0000	1.132
+++ sys/kern/sys_pipe.c	4 Oct 2011 18:02:42 -0000
@@ -255,9 +255,8 @@
 		return EINVAL;
 	p = curproc;
 	rpipe = wpipe = NULL;
-	if (pipe_create(&rpipe, pipe_rd_cache) ||
-	    pipe_create(&wpipe, pipe_wr_cache)) {
-		error = ENOMEM;
+	if ((error = pipe_create(&rpipe, pipe_rd_cache)) ||
+	    (error = pipe_create(&wpipe, pipe_wr_cache))) {
 		goto free2;
 	}
 	rpipe->pipe_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NONE);

>Release-Note:

>Audit-Trail:
From: "Alan Barrett" <apb@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/45423 CVS commit: src/sys/kern
Date: Wed, 5 Oct 2011 13:30:24 +0000

 Module Name:	src
 Committed By:	apb
 Date:		Wed Oct  5 13:30:24 UTC 2011

 Modified Files:
 	src/sys/kern: sys_pipe.c

 Log Message:
 When pipe1() calls pipe_create() and it fails, use the error
 result from pipe_create(), don't assume it will always be ENOMEM.

 From PR 45423 by Greg Woods.


 To generate a diff of this commit:
 cvs rdiff -u -r1.132 -r1.133 src/sys/kern/sys_pipe.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: apb@NetBSD.org
State-Changed-When: Wed, 05 Oct 2011 13:56:07 +0000
State-Changed-Why:
patch applied.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.