Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Oct 2004 02:09:51 -0400
From:      Brian Fundakowski Feldman <green@freebsd.org>
To:        Pawel Malachowski <pawmal-posting@freebsd.lublin.pl>
Cc:        ipfw@freebsd.org
Subject:   Re: (not) Protecting of case IP_FW_GET.
Message-ID:  <20041008060950.GA980@green.homeunix.org>
In-Reply-To: <20040825113822.GC57463@shellma.zin.lublin.pl>
References:  <20040825110455.GB57463@shellma.zin.lublin.pl> <20040825111911.GE92931@elvis.mu.org> <20040825113822.GC57463@shellma.zin.lublin.pl>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Aug 25, 2004 at 01:38:22PM +0200, Pawel Malachowski wrote:
> On Wed, Aug 25, 2004 at 01:19:11PM +0200, Maxime Henrion wrote:
> 
> > > Another thing, in HEAD, there are three mallocs with M_WAITOK flag, only
> > > one of them checks if malloc succeed (lookup tables code) and returns
> > > ENOMEM, if not. Another two are assuming malloc will always succeed.
> > > In RELENG_4, result is checked and ENOBUFS (why not ENOMEM?) is returned
> > > if malloc failed.
> > 
> > The case where it checks the return value of malloc() is wrong.  When
> > called with the M_WAITOK flag, malloc() is not supposed to return NULL.
> 
> malloc(9) states that. What would happen, if one tries to malloc more
> memory than we physically have, with M_WAITOK flag -- will it eat all
> available memory and wait forever for more?

No, it would crash the kernel.  You are only supposed to make "reasonable"
request for memory.

-- 
Brian Fundakowski Feldman                           \'[ FreeBSD ]''''''''''\
  <> green@FreeBSD.org                               \  The Power to Serve! \
 Opinions expressed are my own.                       \,,,,,,,,,,,,,,,,,,,,,,\


Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041008060950.GA980>