Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci Fix error branch in wpi(4) firmware loading.



details:   https://anonhg.NetBSD.org/src/rev/69d307c34a2d
branches:  trunk
changeset: 780697:69d307c34a2d
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Aug 04 03:52:46 2012 +0000

description:
Fix error branch in wpi(4) firmware loading.

Fixes panic if firmware is not available.

diffstat:

 sys/dev/pci/if_wpi.c |  11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diffs (39 lines):

diff -r 7fea96485796 -r 69d307c34a2d sys/dev/pci/if_wpi.c
--- a/sys/dev/pci/if_wpi.c      Sat Aug 04 03:51:27 2012 +0000
+++ b/sys/dev/pci/if_wpi.c      Sat Aug 04 03:52:46 2012 +0000
@@ -1,4 +1,4 @@
-/*  $NetBSD: if_wpi.c,v 1.52 2012/06/02 21:36:45 dsl Exp $    */
+/*  $NetBSD: if_wpi.c,v 1.53 2012/08/04 03:52:46 riastradh Exp $    */
 
 /*-
  * Copyright (c) 2006, 2007
@@ -18,7 +18,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wpi.c,v 1.52 2012/06/02 21:36:45 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wpi.c,v 1.53 2012/08/04 03:52:46 riastradh Exp $");
 
 /*
  * Driver for Intel PRO/Wireless 3945ABG 802.11 network adapters.
@@ -1148,7 +1148,7 @@
        /* load firmware image from disk */
        if ((error = firmware_open("if_wpi","iwlwifi-3945.ucode", &fw)) != 0) {
                aprint_error_dev(sc->sc_dev, "could not read firmware file\n");
-               goto fail1;
+               goto fail0;
        }
 
        wpi_firmware_size = firmware_get_size(fw);
@@ -1192,8 +1192,9 @@
        firmware_free(wpi_firmware_image, wpi_firmware_size);
 fail1:
        firmware_close(fw);
-       if (--wpi_firmware_users == 0)
-               firmware_free(wpi_firmware_image, wpi_firmware_size);
+fail0:
+       wpi_firmware_users--;
+       KASSERT(wpi_firmware_users == 0);
        mutex_exit(&wpi_firmware_mutex);
        return error;
 }



Home | Main Index | Thread Index | Old Index