Skip to contentSkip to conversation

New: fw_card_add adds card to the list even on enable failure

Bug 12592 Stefan Richter 1 participant 1 message Feb 1, 2009 2 messages not in the archive Firewire

lore
Share & tools
lore
#2 lore raw
In reply to a message not in the archive

Date: Sun, 1 Feb 2009 01:29:35 -0800 (PST)
From: Petr Vandrovec <[email protected]>
Subject: firewire: core: Remove card from list of cards when enable fails

After a controller initialization failure, addition of another card got stuck due to card_list corruption.

---
 drivers/firewire/fw-card.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/firewire/fw-card.c +8 -1
Index: linux/drivers/firewire/fw-card.c
===================================================================
@@ -412,6 +412,7 @@ fw_card_add(struct fw_card *card,
 {
 	u32 *config_rom;
 	size_t length;
+	int err;
 
 	card->max_receive = max_receive;
 	card->link_speed = link_speed;
@@ -422,7 +423,13 @@ fw_card_add(struct fw_card *card,
 	list_add_tail(&card->link, &card_list);
 	mutex_unlock(&card_mutex);
 
-	return card->driver->enable(card, config_rom, length);
+	err = card->driver->enable(card, config_rom, length);
+	if (err < 0) {
+		mutex_lock(&card_mutex);
+		list_del(&card->link);
+		mutex_unlock(&card_mutex);
+	}
+	return err;
 }
 EXPORT_SYMBOL(fw_card_add);
 
Signature · 3 lines
Stefan Richter
-=====-==--= --=- ----=
http://arcgraph.de/sr/