From nobody@FreeBSD.org  Fri Mar  8 20:17:59 2002
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id 45F1937B400
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  8 Mar 2002 20:16:39 -0800 (PST)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.6/8.11.6) id g294Gde94327;
	Fri, 8 Mar 2002 20:16:39 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200203090416.g294Gde94327@freefall.freebsd.org>
Date: Fri, 8 Mar 2002 20:16:39 -0800 (PST)
From: nobody <nobody@nobody.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: a small code update
X-Send-Pr-Version: www-1.0

>Number:         35700
>Category:       kern
>Synopsis:       a small code update
>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:   Fri Mar 08 20:20:00 PST 2002
>Closed-Date:    Sun Dec 08 09:39:08 PST 2002
>Last-Modified:  Sun Dec 08 09:39:08 PST 2002
>Originator:     nobody
>Release:        4.5
>Organization:
nobody.com
>Environment:
FreeBSD bsd 4.5-STABLE FreeBSD 4.5-STABLE #11: Tue Jan 29 20:22:14 PST 2002 root@bsd:/usr/src/sys/compile/MYKERN  i386
>Description:
      found a minor bug in the bpf code.  Unified diff included:

# more /tmp/bpfdiffs
--- /usr/src/sys/net/bpfold.c   Fri Mar  8 17:18:45 2002
+++ /usr/src/sys/net/bpf.c      Fri Mar  8 17:26:01 2002
@@ -990,7 +990,9 @@
                return (EINVAL);

        size = flen * sizeof(*fp->bf_insns);
-       fcode = (struct bpf_insn *)malloc(size, M_BPF, M_WAITOK);
+       if((fcode = (struct bpf_insn *)malloc(size, M_BPF, M_WAITOK)) == NULL)
+            return (EINVAL);
+
        if (copyin((caddr_t)fp->bf_insns, (caddr_t)fcode, size) == 0 &&
            bpf_validate(fcode, (int)flen)) {
                s = splimp();
>How-To-Repeat:
      
>Fix:
      
>Release-Note:
>Audit-Trail:

From: Dima Dorfman <dima@trit.org>
To: nobody <nobody@nobody.com>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: kern/35700: a small code update 
Date: Sat, 09 Mar 2002 05:32:23 +0000

 nobody <nobody@nobody.com> wrote:
 > # more /tmp/bpfdiffs
 > --- /usr/src/sys/net/bpfold.c   Fri Mar  8 17:18:45 2002
 > +++ /usr/src/sys/net/bpf.c      Fri Mar  8 17:26:01 2002
 > @@ -990,7 +990,9 @@
 >                 return (EINVAL);
 > 
 >         size = flen * sizeof(*fp->bf_insns);
 > -       fcode = (struct bpf_insn *)malloc(size, M_BPF, M_WAITOK);
 > +       if((fcode = (struct bpf_insn *)malloc(size, M_BPF, M_WAITOK)) == NULL)
 > +            return (EINVAL);
 
 No, the original is right; kernel malloc won't return NULL if M_WAITOK
 is specified.
State-Changed-From-To: open->closed 
State-Changed-By: iedowse 
State-Changed-When: Sun Dec 8 09:38:07 PST 2002 
State-Changed-Why:  

malloc(..., M_WAITOK) cannot return NULL, so the change is unnecessary. 

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