git: 9front

Download patch

ref: 03da1b574954cd1425bc024a5ced1f0d29b64428
parent: edf1614309e7fd4a7c5b56912bb250d487a4172e
author: cinap_lenrek <cinap_lenrek@gmx.de>
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;
 
--