Skip to contentSkip to conversation

starfire: clean up properly if firmware loading fails

PATCH Applied [email protected] 3 participants 4 messages Jan 27, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 starfire: clean up properly if firmware loading fails

From: Ben Hutchings <[email protected]>

netdev_open() will return without cleaning up net device or hardware state if firmware loading fails. This results in a BUG() on a second attempt to bring the interface up, reported in
<http://bugzilla.kernel.org/show_bug.cgi?id=15117>, and probably has even worse effects if the driver is removed afterwards.

Call netdev_close() to clean up on failure.

Addresses http://bugzilla.kernel.org/show_bug.cgi?id=15091

---

 drivers/net/starfire.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/starfire.c renamed from drivers/net/starfire.c~starfire-clean-up-properly-if-firmware-loading-fails +4 -1
diff -puN drivers/net/starfire.c~starfire-clean-up-properly-if-firmware-loading-fails drivers/net/starfire.c
@@ -1063,7 +1063,7 @@ static int netdev_open(struct net_device
 	if (retval) {
 		printk(KERN_ERR "starfire: Failed to load firmware \"%s\"\n",
 		       FIRMWARE_RX);
-		return retval;
+		goto out_init;
 	}
 	if (fw_rx->size % 4) {
 		printk(KERN_ERR "starfire: bogus length %zu in \"%s\"\n",
@@ -1108,6 +1108,9 @@ out_tx:
 	release_firmware(fw_tx);
 out_rx:
 	release_firmware(fw_rx);
+out_init:
+	if (retval)
+		netdev_close(dev);
 	return retval;
 }
 

_

maintainer Applied
#1 lore raw

From: [email protected]
Date: Tue, 26 Jan 2010 20:27:09 -0800

Quoted 10 lines

From: Ben Hutchings <[email protected]>

netdev_open() will return without cleaning up net device or hardware state if firmware loading fails. This results in a BUG() on a second attempt to bring the interface up, reported in
<http://bugzilla.kernel.org/show_bug.cgi?id=15117>, and probably has even worse effects if the driver is removed afterwards.

Call netdev_close() to clean up on failure.

Quoted 8 lines

Addresses http://bugzilla.kernel.org/show_bug.cgi?id=15091

Applied, thanks everyone!

#2 lore raw
In reply to [email protected]
Quoted 7 lines · On Tue, 2010-01-26 at 20:27 -0800, [email protected] wrote:

From: Ben Hutchings <[email protected]>

netdev_open() will return without cleaning up net device or hardware state if firmware loading fails. This results in a BUG() on a second attempt to bring the interface up, reported in
<http://bugzilla.kernel.org/show_bug.cgi?id=15117>, and probably has even worse effects if the driver is removed afterwards.

David, please correct the URL above before applying the patch so I don't continue to look like an idiot. :-) It should be
<http://bugzilla.kernel.org/show_bug.cgi?id=15091> as added by Andrew below.

Ben.

Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
maintainer
#3 lore raw

From: Ben Hutchings <[email protected]>
Date: Wed, 27 Jan 2010 04:58:17 +0000

Quoted 9 lines · On Tue, 2010-01-26 at 20:27 -0800, [email protected] wrote:
Quoted 7 lines

From: Ben Hutchings <[email protected]>

netdev_open() will return without cleaning up net device or hardware state if firmware loading fails. This results in a BUG() on a second attempt to bring the interface up, reported in
<http://bugzilla.kernel.org/show_bug.cgi?id=15117>, and probably has even worse effects if the driver is removed afterwards.

Quoted 4 lines

David, please correct the URL above before applying the patch so I don't continue to look like an idiot. :-) It should be
<http://bugzilla.kernel.org/show_bug.cgi?id=15091> as added by Andrew below.

Done.