Subject: kern/28063: free(NULL, ...) should be noted in free(9) manual page
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <kent@NetBSD.org>
List: netbsd-bugs
Date: 11/07/2004 06:05:20
>Number: 28063
>Category: kern
>Synopsis: free(NULL, ...) should be noted in free(9) manual page
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: kern-bug-people
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: doc-bug
>Submitter-Id: net
>Arrival-Date: Sun Nov 07 06:06:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator: TAMURA Kent
>Release: -current
>Organization:
>Environment:
NetBSD p4 2.99.10 NetBSD 2.99.10 (P4MP) #148: Sun Nov 7 14:55:04 JST 2004 kent@p4:/home/kent/compile/P4MP i386
>Description:
Unlike free(3), in-kernel free(9) crashes by free(NULL, ...)
call.
>How-To-Repeat:
free(NULL, M_xxx); in kernel code.
>Fix:
IMO, free(9) should accept NULL.
diff -u -r1.90 kern_malloc.c
--- kern_malloc.c 4 Sep 2004 23:30:07 -0000 1.90
+++ kern_malloc.c 7 Nov 2004 06:02:56 -0000
@@ -479,6 +479,9 @@
long alloc, copysize;
#endif
+ if (addr == NULL)
+ return;
+
#ifdef MALLOC_DEBUG
if (debug_free(addr, ksp))
return;
The manual page of free(9) must mention behavior for NULL
regardless of crash by NULL or not.
>Release-Note:
>Audit-Trail:
>Unformatted: