Thread (6 messages) 6 messages, 2 authors, 2016-04-01

Re: [PATCH] md/bitmap: call bitmap_destroy in case bitmap_create failed

From: Shaohua Li <shli@kernel.org>
Date: 2016-03-25 22:02:10

On Fri, Mar 25, 2016 at 07:00:14PM +0800, Guoqing Jiang wrote:
quoted hunk ↗ jump to hunk
If bitmap_create returns an error, bitmap_destroy must be
called to do clean up.

Signed-off-by: Guoqing Jiang <redacted>
---
 drivers/md/bitmap.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 7df6b4f..ba908e7 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -1865,8 +1865,10 @@ int bitmap_copy_from_slot(struct mddev *mddev, int slot,
 	struct bitmap_counts *counts;
 	struct bitmap *bitmap = bitmap_create(mddev, slot);
 
-	if (IS_ERR(bitmap))
+	if (IS_ERR(bitmap)) {
+		bitmap_destroy(mddev);
 		return PTR_ERR(bitmap);
+	}
bitmap_create doesn't set mddev->bitmap, so bitmap_destroy will do nothing.
is this because of reference leak of sysfs_can_clear? can we move
sysfs_put(bitmap->sysfs_can_clear); to bitmap_free?

Thanks,
Shaohua
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help