From: Milan Broz <[email-masked]>

Do not process sysfs attributes when device is being destroyed.

Otherwise code can cause 
  BUG_ON(test_bit(DMF_FREEING, &md->flags));
in dm_put() call.

Cc: [email-masked]
Signed-off-by: Milan Broz <[email-masked]>
Signed-off-by: Alasdair G Kergon <[email-masked]>

---
 drivers/md/dm.c |    4 ++++
 1 file changed, 4 insertions(+)

Index: linux-2.6.30/drivers/md/dm.c
===================================================================
--- linux-2.6.30.orig/drivers/md/dm.c
+++ linux-2.6.30/drivers/md/dm.c
@@ -1777,6 +1777,10 @@ struct mapped_device *dm_get_from_kobjec
 	if (&md->kobj != kobj)
 		return NULL;
 
+	if (test_bit(DMF_FREEING, &md->flags) ||
+	    test_bit(DMF_DELETING, &md->flags))
+		return NULL;
+
 	dm_get(md);
 	return md;
 }