* [PATCH] make mempool_destroy resilient against NULL pointers.
@ 2005-04-09 1:41 Jesper Juhl
2005-04-09 1:41 ` Andrew Morton
0 siblings, 1 reply; 4+ messages in thread
From: Jesper Juhl @ 2005-04-09 1:41 UTC (permalink / raw)
To: LKML
Cc: Ingo Molnar, Arjan van de Ven, ecashin, Greg K-H, Jens Axboe,
Andrew Morton
General rule (as I understand it) is that functions that free resources
should handle being passed NULL pointers - mempool_destroy() will
currently explode if passed a NULL pointer, the patch below makes it safe
to pass it NULL.
Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>
---
mempool.c | 2 ++
1 files changed, 2 insertions(+)
--- linux-2.6.12-rc2-mm2-orig/mm/mempool.c 2005-04-05 21:21:56.000000000 +0200
+++ linux-2.6.12-rc2-mm2/mm/mempool.c 2005-04-09 03:33:58.000000000 +0200
@@ -176,6 +176,8 @@ EXPORT_SYMBOL(mempool_resize);
*/
void mempool_destroy(mempool_t *pool)
{
+ if (!pool)
+ return;
if (pool->curr_nr != pool->min_nr)
BUG(); /* There were outstanding elements */
free_pool(pool);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] make mempool_destroy resilient against NULL pointers.
2005-04-09 1:41 [PATCH] make mempool_destroy resilient against NULL pointers Jesper Juhl
@ 2005-04-09 1:41 ` Andrew Morton
2005-04-09 1:46 ` Jesper Juhl
2005-04-24 1:32 ` Jesper Juhl
0 siblings, 2 replies; 4+ messages in thread
From: Andrew Morton @ 2005-04-09 1:41 UTC (permalink / raw)
To: Jesper Juhl; +Cc: linux-kernel, mingo, arjan, ecashin, greg, axboe
Jesper Juhl <juhl-lkml@dif.dk> wrote:
>
>
> General rule (as I understand it) is that functions that free resources
> should handle being passed NULL pointers - mempool_destroy() will
> currently explode if passed a NULL pointer, the patch below makes it safe
> to pass it NULL.
The best response to mempool_destroy(0) is an oops. There's no legitimate
reason for doing it.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] make mempool_destroy resilient against NULL pointers.
2005-04-09 1:41 ` Andrew Morton
@ 2005-04-09 1:46 ` Jesper Juhl
2005-04-24 1:32 ` Jesper Juhl
1 sibling, 0 replies; 4+ messages in thread
From: Jesper Juhl @ 2005-04-09 1:46 UTC (permalink / raw)
To: Andrew Morton
Cc: Jesper Juhl, linux-kernel, mingo, arjan, ecashin, greg, axboe
On Fri, 8 Apr 2005, Andrew Morton wrote:
> Jesper Juhl <juhl-lkml@dif.dk> wrote:
> >
> >
> > General rule (as I understand it) is that functions that free resources
> > should handle being passed NULL pointers - mempool_destroy() will
> > currently explode if passed a NULL pointer, the patch below makes it safe
> > to pass it NULL.
>
> The best response to mempool_destroy(0) is an oops. There's no legitimate
> reason for doing it.
>
Ok, ignore the patch then.
--
Jesper
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] make mempool_destroy resilient against NULL pointers.
2005-04-09 1:41 ` Andrew Morton
2005-04-09 1:46 ` Jesper Juhl
@ 2005-04-24 1:32 ` Jesper Juhl
1 sibling, 0 replies; 4+ messages in thread
From: Jesper Juhl @ 2005-04-24 1:32 UTC (permalink / raw)
To: Andrew Morton
Cc: Jesper Juhl, linux-kernel, mingo, arjan, ecashin, greg, axboe
On Fri, 8 Apr 2005, Andrew Morton wrote:
> Jesper Juhl <juhl-lkml@dif.dk> wrote:
> >
> >
> > General rule (as I understand it) is that functions that free resources
> > should handle being passed NULL pointers - mempool_destroy() will
> > currently explode if passed a NULL pointer, the patch below makes it safe
> > to pass it NULL.
>
> The best response to mempool_destroy(0) is an oops. There's no legitimate
> reason for doing it.
>
Sorry to bring this up again but, take a look at the patch by
ecashin@coraid.com titled "[PATCH] aoe 5/12: don't try to free null
bufpool" http://grmso.net:8090/commit/03347936afcba990525736ae39daa13f643eac5f/diff/fa83c2ddd4293bd8bcaeeaf14bfdbf2fbe810420/
That's exactely the reason why the patch I submitted should be applied, to
avoid having to do such checks all over the place in other code and
instead just do it in one location. With this patch in place, the patch to
aoedev.c would not have been needed.
Or am I still misunderstanding something.
--
Jesper
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-04-24 1:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-09 1:41 [PATCH] make mempool_destroy resilient against NULL pointers Jesper Juhl
2005-04-09 1:41 ` Andrew Morton
2005-04-09 1:46 ` Jesper Juhl
2005-04-24 1:32 ` Jesper Juhl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®