kern/140441: order of arguments for mtx_init is incorrect in
uipc_syscalls.c
Kouhei Ueno
k.ueno at fillot.jp
Tue Nov 10 07:00:17 UTC 2009
>Number: 140441
>Category: kern
>Synopsis: order of arguments for mtx_init is incorrect in uipc_syscalls.c
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Tue Nov 10 07:00:10 UTC 2009
>Closed-Date:
>Last-Modified:
>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 at 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:
>Unformatted:
More information about the freebsd-bugs
mailing list