Module Name:    src
Committed By:   khorben
Date:           Sat Mar  7 11:52:53 UTC 2015

Modified Files:
        src/sys/dev/pci: if_iwm.c

Log Message:
Avoid kmem_free(NULL) in iwm_read_firmware()

This code path can be hit if the firmware failed to load, for instance
if the file is not present on the filesystem. In this case
firmware_open() fails, and fw->fw_rawdata never gets allocated in the
first place.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/pci/if_iwm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_iwm.c
diff -u src/sys/dev/pci/if_iwm.c:1.26 src/sys/dev/pci/if_iwm.c:1.27
--- src/sys/dev/pci/if_iwm.c:1.26	Wed Mar  4 16:55:11 2015
+++ src/sys/dev/pci/if_iwm.c	Sat Mar  7 11:52:53 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_iwm.c,v 1.26 2015/03/04 16:55:11 nonaka Exp $	*/
+/*	$NetBSD: if_iwm.c,v 1.27 2015/03/07 11:52:53 khorben Exp $	*/
 /*	OpenBSD: if_iwm.c,v 1.35 2015/03/04 15:18:12 jsg Exp	*/
 
 /*
@@ -105,7 +105,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.26 2015/03/04 16:55:11 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.27 2015/03/07 11:52:53 khorben Exp $");
 
 #include <sys/param.h>
 #include <sys/conf.h>
@@ -804,7 +804,7 @@ iwm_read_firmware(struct iwm_softc *sc)
 		fw->fw_status = IWM_FW_STATUS_DONE;
 	wakeup(&sc->sc_fw);
 
-	if (error) {
+	if (error && fw->fw_rawdata != NULL) {
 		kmem_free(fw->fw_rawdata, fw->fw_rawsize);
 		fw->fw_rawdata = NULL;
 	}

Reply via email to