Skip to contentSkip to conversation

dm-log: fix io_client_destroy leak

RFC PATCH In review Takahiro Yasui 2 participants 2 messages Nov 26, 2008 – Dec 16, 2008 Device mapper

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/4 dm-log: fix io_client_destroy leak

In create_log_context function, dm_io_client_destroy function needs to be called, when memory allocation of disk_header, sync_bits and recovering_bits failed, but dm_io_client_destroy is not called. This patch fixes it.

---
 drivers/md/dm-log.c |    5 +++++
 1 file changed, 5 insertions(+)
drivers/md/dm-log.c +5 -0
Index: linux-2.6.28-rc4/drivers/md/dm-log.c
===================================================================
@@ -467,6 +467,7 @@ static int create_log_context(struct dm_
 		lc->disk_header = vmalloc(buf_size);
 		if (!lc->disk_header) {
 			DMWARN("couldn't allocate disk log buffer");
+			dm_io_client_destroy(lc->io_req.client);
 			kfree(lc);
 			return -ENOMEM;
 		}
@@ -483,6 +484,8 @@ static int create_log_context(struct dm_
 		if (!dev)
 			vfree(lc->clean_bits);
 		vfree(lc->disk_header);
+		if (dev)
+			dm_io_client_destroy(lc->io_req.client);
 		kfree(lc);
 		return -ENOMEM;
 	}
@@ -496,6 +499,8 @@ static int create_log_context(struct dm_
 		if (!dev)
 			vfree(lc->clean_bits);
 		vfree(lc->disk_header);
+		if (dev)
+			dm_io_client_destroy(lc->io_req.client);
 		kfree(lc);
 		return -ENOMEM;
 	}
#1 lore raw

ACK - reviewed but not tested.

brassow

Quoted 46 lines · Takahiro Yasui

In create_log_context function, dm_io_client_destroy function needs to be called, when memory allocation of disk_header, sync_bits and recovering_bits failed, but dm_io_client_destroy is not called. This patch fixes it.

---
drivers/md/dm-log.c | 5 +++++

1 file changed, 5 insertions(+)

Index: linux-2.6.28-rc4/drivers/md/dm-log.c
===================================================================

drivers/md/dm-log.c +5 -1
@@ -467,6 +467,7 @@ static int create_log_context(struct dm_
 		lc->disk_header = vmalloc(buf_size);
 		if (!lc->disk_header) {
 			DMWARN("couldn't allocate disk log buffer");
+			dm_io_client_destroy(lc->io_req.client);
 			kfree(lc);
 			return -ENOMEM;
 		}
@@ -483,6 +484,8 @@ static int create_log_context(struct dm_
 		if (!dev)
 			vfree(lc->clean_bits);
 		vfree(lc->disk_header);
+		if (dev)
+			dm_io_client_destroy(lc->io_req.client);
 		kfree(lc);
 		return -ENOMEM;
 	}
@@ -496,6 +499,8 @@ static int create_log_context(struct dm_
 		if (!dev)
 			vfree(lc->clean_bits);
 		vfree(lc->disk_header);
+		if (dev)
+			dm_io_client_destroy(lc->io_req.client);
 		kfree(lc);
 		return -ENOMEM;
 	}
 
--

dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel