From nobody@FreeBSD.org  Tue Nov 10 06:51:32 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 15DC41065670
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 10 Nov 2009 06:51:32 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 04B958FC17
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 10 Nov 2009 06:51:32 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id nAA6pVpS037411
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 10 Nov 2009 06:51:31 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id nAA6pVkE037410;
	Tue, 10 Nov 2009 06:51:31 GMT
	(envelope-from nobody)
Message-Id: <200911100651.nAA6pVkE037410@www.freebsd.org>
Date: Tue, 10 Nov 2009 06:51:31 GMT
From: Kouhei Ueno <k.ueno@fillot.jp>
To: freebsd-gnats-submit@FreeBSD.org
Subject: order of arguments for mtx_init is incorrect in uipc_syscalls.c
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         140441
>Category:       kern
>Synopsis:       [kernel] [patch] order of arguments for mtx_init is incorrect in uipc_syscalls.c
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Nov 10 07:00:10 UTC 2009
>Closed-Date:    Fri Jan 08 23:16:05 CET 2010
>Last-Modified:  Fri Jan 08 23:16:05 CET 2010
>Originator:     Kouhei Ueno
>Release:        FreeBSD 8.0-RC1 i386
>Organization:
Fillot Inc.
>Environment:
FreeBSD burmese-bsddev.home.nyaxtstep.com 8.0-RC1 FreeBSD 8.0-RC1 #0: Thu Oct 15 20:36:40 JST 2009     root@burmese-bsddev.home.nyaxtstep.com:/usr/src/sys/i386/compile/IZNA  i386

>Description:
In sendfile implementation, kern_sendfile, mtx_init(9) is called with its arguments in incorrect order. The third argument should be type, and the fourth argument should be opts. These are swapped in the implementation.

Fortunately, MTX_DEF is defined to be zero (which would equal NULL), so the original code will not cause any problem. But still it is very confusing to read.
>How-To-Repeat:
don't know
>Fix:
patch to uipc_syscalls.c

--- uipc_syscalls.c     2009-08-03 17:13:06.000000000 +0900
+++ uipc_syscalls.c.fix 2009-11-10 15:17:18.000000000 +0900
@@ -1885,7 +1885,7 @@
        if (uap->flags & SF_SYNC) {
                sfs = malloc(sizeof *sfs, M_TEMP, M_WAITOK);
                memset(sfs, 0, sizeof *sfs);
-               mtx_init(&sfs->mtx, "sendfile", MTX_DEF, 0);
+               mtx_init(&sfs->mtx, "sendfile", NULL, MTX_DEF);
                cv_init(&sfs->cv, "sendfile");
        }



>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->patched 
State-Changed-By: brueffer 
State-Changed-When: Fri Jan 8 23:12:24 CET 2010 
State-Changed-Why:  



Responsible-Changed-From-To: freebsd-bugs->mjacob 
Responsible-Changed-By: brueffer 
Responsible-Changed-When: Fri Jan 8 23:12:24 CET 2010 
Responsible-Changed-Why:  


http://www.freebsd.org/cgi/query-pr.cgi?pr=140441 
State-Changed-From-To: patched->closed 
State-Changed-By: brueffer 
State-Changed-When: Fri Jan 8 23:15:07 CET 2010 
State-Changed-Why:  
MFC done. 


Responsible-Changed-From-To: mjacob->freebsd-bugs 
Responsible-Changed-By: brueffer 
Responsible-Changed-When: Fri Jan 8 23:15:07 CET 2010 
Responsible-Changed-Why:  
Already merged, my bad. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=140441 
>Unformatted:
