From: Marcus Alanen <marcus@infa.abo.fi>
To: balbir_soni@hotmail.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Trivial patch against mempool
Date: Fri, 22 Feb 2002 23:40:43 +0200 [thread overview]
Message-ID: <200202222140.XAA16750@infa.abo.fi> (raw)
In-Reply-To: <F24fGB9wIWXLU9778dv00003562@hotmail.com>
In-Reply-To: <F24fGB9wIWXLU9778dv00003562@hotmail.com>
>Check if the alloc_fn and free_fn are not NULL. The caller generally
>ensures that alloc_fn and free_fn are valid. It would not harm
>to check. This makes the checking in mempool_create() more complete.
>
>
>--- mempool.c.org Fri Feb 22 12:00:58 2002
>+++ mempool.c Fri Feb 22 12:01:13 2002
>@@ -35,7 +35,7 @@
> int i;
>
> pool = kmalloc(sizeof(*pool), GFP_KERNEL);
>- if (!pool)
>+ if (!pool || !alloc_fn || !free_fn)
> return NULL;
> memset(pool, 0, sizeof(*pool));
>
A successful allocation with alloc_fn or free_fn equal to NULL
would return NULL, without freeing pool. => This check would
leak memory? Wouldn't it be better to check for !alloc_fn || !free_fn
before the kmalloc()
--
Marcus Alanen
maalanen@abo.fi
next prev parent reply other threads:[~2002-02-22 21:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-02-22 20:28 [PATCH] Trivial patch against mempool Balbir Singh
2002-02-22 21:40 ` Marcus Alanen [this message]
2002-02-23 0:02 ` Benjamin LaHaise
-- strict thread matches above, loose matches on Subject: below --
2002-02-22 21:59 Balbir Singh
2002-02-23 0:37 Balbir Singh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200202222140.XAA16750@infa.abo.fi \
--to=marcus@infa.abo.fi \
--cc=balbir_soni@hotmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.