Skip to contentSkip to conversation

dm: check era->md is non-NULL before closing it

PATCH In review [email protected] 2 participants 2 messages May 20, 2014 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dm: check era->md is non-NULL before closing it

In era_ctr(), era->md remain NULL until it's set after metadata_open(). On the other hand, era_destroy() assume era->md is non-NULL and it is called by era_ctr() before initializing the value.

This patch just checks if era->md is non-NULL.

---
 drivers/md/dm-era-target.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/md/dm-era-target.c +2 -1
index 414dad4..ad913cd 100644
@@ -1391,7 +1391,8 @@ static int era_is_congested(struct dm_target_callbacks *cb, int bdi_bits)
 
 static void era_destroy(struct era *era)
 {
-	metadata_close(era->md);
+	if (era->md)
+		metadata_close(era->md);
 
 	if (era->wq)
 		destroy_workqueue(era->wq);
Signature · 1 line
1.9.2
#1 lore raw
Quoted 3 lines · On Tue, May 20, 2014 at 12:53:56PM +0900, [email protected] wrote:

In era_ctr(), era->md remain NULL until it's set after metadata_open(). On the other hand, era_destroy() assume era->md is non-NULL and it is called by era_ctr() before initializing the value.

Thanks. This change went into my tree on the 11th March, I'll chase and see why it's not upstream yet.

- Joe