Skip to contentSkip to conversation

kaweth: fix firmware download

PATCH In review Oliver Neukum 2 participants 4 messages Aug 17, 2016

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

PATCH 1/2 kaweth: fix firmware download

This fixes the oops discovered by the Umap2 project and Alan Stern. The intf member needs to be set before the firmware is downloaded.

---
 drivers/net/usb/kaweth.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/usb/kaweth.c +1 -2
index 770212b..37bf715 100644
@@ -1029,6 +1029,7 @@ static int kaweth_probe(
 	kaweth = netdev_priv(netdev);
 	kaweth->dev = udev;
 	kaweth->net = netdev;
+	kaweth->intf = intf;
 
 	spin_lock_init(&kaweth->device_lock);
 	init_waitqueue_head(&kaweth->term_wait);
@@ -1139,8 +1140,6 @@ err_fw:
 
 	dev_dbg(dev, "Initializing net device.\n");
 
-	kaweth->intf = intf;
-
 	kaweth->tx_urb = usb_alloc_urb(0, GFP_KERNEL);
 	if (!kaweth->tx_urb)
 		goto err_free_netdev;
Signature · 1 line
2.1.4
#1 lore raw

PATCH 2/2 kaweth: fix oops upon failed memory allocation

Just return an error upon failure.

---
 drivers/net/usb/kaweth.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/usb/kaweth.c +2 -0
index 37bf715..3cd6906 100644
@@ -1049,6 +1049,8 @@ static int kaweth_probe(
 		/* Download the firmware */
 		dev_info(dev, "Downloading firmware...\n");
 		kaweth->firmware_buf = (__u8 *)__get_free_page(GFP_KERNEL);
+		if (!kaweth->firmware_buf)
+				return -ENOMEM;
 		if ((result = kaweth_download_firmware(kaweth,
 						      "kaweth/new_code.bin",
 						      100,
Signature · 1 line
2.1.4
#2 lore raw

Re: [PATCH 2/2] kaweth: fix oops upon failed memory allocation

Quoted 12 lines · Oliver Neukum

Just return an error upon failure.

---
 drivers/net/usb/kaweth.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/usb/kaweth.c +0 -0
index 37bf715..3cd6906 100644

drivers/net/usb/kaweth.c static int kaweth_probe( · line 1053

Quoted 5 lines
drivers/net/usb/kaweth.c +2 -0
@@ -1049,6 +1049,8 @@ static int kaweth_probe(
 		/* Download the firmware */
 		dev_info(dev, "Downloading firmware...\n");
 		kaweth->firmware_buf = (__u8 *)__get_free_page(GFP_KERNEL);
+		if (!kaweth->firmware_buf)
+				return -ENOMEM;

Eh, that should be "goto err_free_netdev;", shouldn't it?

Bjørn

#3 lore raw

Re: [PATCH 2/2] kaweth: fix oops upon failed memory allocation

Quoted 3 lines · Bjørn Mork

Oliver Neukum <[email protected]> writes:

Eh, that should be "goto err_free_netdev;", shouldn't it?

Right, thanks. Fixed version coming up.

Regards
Oliver