Thread (6 messages) 6 messages, 3 authors, 2017-11-10

Re: [PATCH 1/2] md: release allocated bitset sync_set

From: Zdenek Kabelac <hidden>
Date: 2017-11-10 10:03:14

Dne 10.11.2017 v 00:32 Shaohua Li napsal(a):
On Wed, Nov 08, 2017 at 01:44:55PM +0100, Zdenek Kabelac wrote:
quoted
Patch fixes kmemleak on md_stop() path used likely only by dm-raid
wrapper. Code of md is using  mddev_put() where both  bitsets
are released however this bitmap freeing is not shared.
what did you mean 'bitmap freeing is not shared' ? The patch doesn't handle
bitmap either.
It only means there is some code to teardown md device which is not shared
between 'md'  and  'dm' wrapper - thus whenever mddev_put() is updated
in some way (adding freeing another object)  same code should be
duplicated into  md_stop()  which is used only by 'dm' (from my
understanding of comment in the source).

IMHO this is not ideal - the code for freeing resources should be sharing more 
code lines...

But as of now - patch works and does exactly what is needed...
quoted
Also set NULL to bio_set and sync_set pointers just like mddev_put is
doing.

Signed-off-by: Zdenek Kabelac <redacted>
---
  drivers/md/md.c | 8 +++++++-
  1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 0ff1bbf6c90e..635ad7c38f67 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -5834,8 +5834,14 @@ void md_stop(struct mddev *mddev)
  	 * This is called from dm-raid
  	 */
  	__md_stop(mddev);
-	if (mddev->bio_set)
+	if (mddev->bio_set) {
  		bioset_free(mddev->bio_set);
+		mddev->bio_set = NULL;
+	}
+	if (mddev->sync_set) {
+		bioset_free(mddev->sync_set);
+		mddev->sync_set = NULL;
+	}
  }
  
  EXPORT_SYMBOL_GPL(md_stop);
-- 
2.15.0

--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help