shithub: riscv

Download patch

ref: 926dd18a7a335c231774288702eb35efb9d1058a
parent: 18b8ae56e8f944df3c9078afd294aad03b204557
author: cinap_lenrek <[email protected]>
date: Sun May 19 21:03:20 EDT 2013

wifi: handle malloc errors in wifiattach()

--- a/sys/src/9/pc/wifi.c
+++ b/sys/src/9/pc/wifi.c
@@ -464,8 +464,14 @@
 	Wifi *wifi;
 
 	wifi = malloc(sizeof(Wifi));
-	wifi->ether = ether;
+	if(wifi == nil)
+		error(Enomem);
 	wifi->iq = qopen(8*1024, 0, 0, 0);
+	if(wifi->iq == nil){
+		free(wifi);
+		error(Enomem);
+	}
+	wifi->ether = ether;
 	wifi->transmit = transmit;
 	wifi->status = Snone;