2005-11-09 22:07:45

by Kiyoshi Ueda

[permalink] [raw]
Subject: [PATCH] dm: memory leak in failed table_load()

Hi Alasdair,

This patch fixes following two problems which occur when "dmsetup load foo"
is executed before the map of the "foo" is created.

o memory leak.
o unable to unload the dm_mod module.

Please consider to apply.

How to reproduce the problem:
# echo "0 10 linear 8:16 0" | dmsetup load foo
(Need to change "8:16" appropriately.)

Patch for 2.6.14:
Signed-off-by: Kiyoshi Ueda <[email protected]>
Signed-off-by: Jun'ichi Nomura <[email protected]>

diff -up 2.6.14/drivers/md/dm-ioctl.c fix/drivers/md/dm-ioctl.c
--- 2.6.14/drivers/md/dm-ioctl.c 2005-10-27 20:02:08.000000000 -0400
+++ fix/drivers/md/dm-ioctl.c 2005-11-09 15:29:59.000000000 -0500
@@ -974,6 +974,7 @@ static int table_load(struct dm_ioctl *p
if (!hc) {
DMWARN("device doesn't appear to be in the dev hash table.");
up_write(&_hash_lock);
+ dm_table_put(t);
return -ENXIO;
}

Thanks,
Kiyoshi Ueda


2005-11-09 22:48:22

by Alasdair G Kergon

[permalink] [raw]
Subject: Re: [PATCH] dm: memory leak in failed table_load()

On Wed, Nov 09, 2005 at 05:07:32PM -0500, Kiyoshi Ueda wrote:
> @@ -974,6 +974,7 @@ static int table_load(struct dm_ioctl *p
> if (!hc) {
> DMWARN("device doesn't appear to be in the dev hash table.");
> up_write(&_hash_lock);
> + dm_table_put(t);
> return -ENXIO;

Well spotted!

Added to dev patchset and will push alongside with some other stuff in a
few days' time.
http://www.kernel.org/pub/linux/kernel/people/agk/patches/2.6/editing/dm-ioctl-missing-put-in-table-load-error-case.patch

Alasdair
--
[email protected]