Skip to contentSkip to conversation

trivial fix to dm-emc.c

PATCH In review Dave Olien 2 participants 2 messages Mar 3, 2005 – Apr 11, 2005 Device mapper

lore
Share & tools
lore

Dave Olien

author
#0 lore raw

PATCH 1/1 trivial fix to dm-emc.c

Here's a trivial fix to the emc hardware
handler module. The old code memset the hardware handler structure to zero AFTER it had initialized the structure's spinlock field to SPIN_LOCK_UNLOCKED. The new patch moves the memset into the hardware handler allocator.

The old code would probably only have a problem if someone ran with spinlock debugging enabled, in which case SPIN_LOCK_UNLOCKED contains the value SPINLOCK_MAGIC.

I have no emc hardware to test this change. However it does compile.

Dave Olien

drivers/md/dm-emc.c +1 -2
diff -ur linux-2.6.11-rc3-udm2-original/drivers/md/dm-emc.c linux-2.6.11-rc3-udm2-emc/drivers/md/dm-emc.c
@@ -227,6 +227,7 @@
 	struct emc_handler *h = kmalloc(sizeof(*h), GFP_KERNEL);
 
 	if (h) {
+		memset(h, 0, sizeof(*h));
 		h->lock = SPIN_LOCK_UNLOCKED;
 	}
 
@@ -263,8 +264,6 @@
 	if (!h)
 		return -ENOMEM;
 	
-	memset(h, 0, sizeof(*h));
-	
 	hwh->context = h;
 	
 	if ((h->short_trespass = short_trespass))
#1 lore raw
Quoted 11 lines · Dave Olien

Here's a trivial fix to the emc hardware
handler module. The old code memset the hardware handler structure to zero AFTER it had initialized the structure's spinlock field to SPIN_LOCK_UNLOCKED. The new patch moves the memset into the hardware handler allocator.

The old code would probably only have a problem if someone ran with spinlock debugging enabled, in which case SPIN_LOCK_UNLOCKED contains the value SPINLOCK_MAGIC.

I have no emc hardware to test this change. However it does compile.

Alasdair, please merge, looks correct.

Quoted 22 lines

diff -ur linux-2.6.11-rc3-udm2-original/drivers/md/dm-emc.c linux-2.6.11-rc3-udm2-emc/drivers/md/dm-emc.c

drivers/md/dm-emc.c +1 -3
@@ -227,6 +227,7 @@
 	struct emc_handler *h = kmalloc(sizeof(*h), GFP_KERNEL);
 
 	if (h) {
+		memset(h, 0, sizeof(*h));
 		h->lock = SPIN_LOCK_UNLOCKED;
 	}
 
@@ -263,8 +264,6 @@
 	if (!h)
 		return -ENOMEM;
 
-	memset(h, 0, sizeof(*h));
-	
 	hwh->context = h;
 
 	if ((h->short_trespass = short_trespass))
 
--
Quoted 4 lines

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

Sincerely,
Lars Marowsky-Brée <[email protected]>

Signature · 3 lines
High Availability & Clustering
SUSE Labs, Research and Development
SUSE LINUX Products GmbH - A Novell Business