NetBSD-Bugs archive

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

Re: kern/44144 (ifconfig causes assertion failure in vfs_lookup.c)



The following reply was made to PR kern/44144; it has been noted by GNATS.

From: David Holland <dholland-bugs%netbsd.org@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: kern/44144 (ifconfig causes assertion failure in vfs_lookup.c)
Date: Wed, 22 Aug 2012 03:37:04 +0000

 On Mon, May 30, 2011 at 03:45:02AM +0000, David Holland wrote:
  >>>  Thank you; I'll try it tomorrow.
  >>  
  >>  Let me know when/if I should commit...
  >  
  >  Slightly updated patch (the previous version now rejects):
 
 Current version, now mostly cosmetic:
 
 Index: if_wpi.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/pci/if_wpi.c,v
 retrieving revision 1.53
 diff -u -p -r1.53 if_wpi.c
 --- if_wpi.c   4 Aug 2012 03:52:46 -0000       1.53
 +++ if_wpi.c   22 Aug 2012 03:33:17 -0000
 @@ -417,8 +417,12 @@ wpi_detach(device_t self, int flags __un
  
        if (sc->fw_used) {
                mutex_enter(&wpi_firmware_mutex);
 -              if (--wpi_firmware_users == 0)
 +              if (--wpi_firmware_users == 0) {
 +                      KASSERT(wpi_firmware_image != NULL);
                        firmware_free(wpi_firmware_image, wpi_firmware_size);
 +                      wpi_firmware_image = NULL;
 +                      wpi_firmware_size = 0;
 +              }
                mutex_exit(&wpi_firmware_mutex);
        }
  
 @@ -1133,6 +1137,7 @@ wpi_load_microcode(struct wpi_softc *sc,
  static int
  wpi_cache_firmware(struct wpi_softc *sc)
  {
 +      static const char fwname[] = "iwlwifi-3945.ucode";
        firmware_handle_t fw;
        int error;
  
 @@ -1146,8 +1151,9 @@ wpi_cache_firmware(struct wpi_softc *sc)
        }
  
        /* 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");
 +      if ((error = firmware_open("if_wpi", fwname, &fw)) != 0) {
 +              aprint_error_dev(sc->sc_dev,
 +                  "Could not open firmware file %s\n", fwname);
                goto fail0;
        }
  
 @@ -1157,29 +1163,33 @@ wpi_cache_firmware(struct wpi_softc *sc)
            WPI_FW_MAIN_TEXT_MAXSZ + WPI_FW_MAIN_DATA_MAXSZ +
            WPI_FW_INIT_TEXT_MAXSZ + WPI_FW_INIT_DATA_MAXSZ +
            WPI_FW_BOOT_TEXT_MAXSZ) {
 -              aprint_error_dev(sc->sc_dev, "invalid firmware file\n");
 +              aprint_error_dev(sc->sc_dev, "Invalid firmware file %s\n",
 +                  fwname);
                error = EFBIG;
                goto fail1;
        }
  
        if (wpi_firmware_size < sizeof (struct wpi_firmware_hdr)) {
                aprint_error_dev(sc->sc_dev,
 -                  "truncated firmware header: %zu bytes\n",
 -                  wpi_firmware_size);
 +                  "Truncated firmware header in %s: %zu bytes\n",
 +                  fwname, wpi_firmware_size);
                error = EINVAL;
 -              goto fail2;
 +              goto fail1;
        }
  
        wpi_firmware_image = firmware_malloc(wpi_firmware_size);
        if (wpi_firmware_image == NULL) {
 -              aprint_error_dev(sc->sc_dev, "not enough memory to stock 
firmware\n");
 +              aprint_error_dev(sc->sc_dev,
 +                  "Not enough memory for firmware %s\n", fwname);
                error = ENOMEM;
                goto fail1;
        }
  
 -      if ((error = firmware_read(fw, 0, wpi_firmware_image, 
wpi_firmware_size)) != 0) {
 -              aprint_error_dev(sc->sc_dev, "can't get firmware\n");
 -              goto fail2;
 +      error = firmware_read(fw, 0, wpi_firmware_image, wpi_firmware_size);
 +      if (error != 0) {
 +              aprint_error_dev(sc->sc_dev,
 +                  "Error reading firmware file %s\n", fwname);
 +              goto fail1;
        }
  
        sc->fw_used = true;
 @@ -1188,13 +1198,16 @@ wpi_cache_firmware(struct wpi_softc *sc)
  
        return 0;
  
 -fail2:
 -      firmware_free(wpi_firmware_image, wpi_firmware_size);
  fail1:
        firmware_close(fw);
  fail0:
        wpi_firmware_users--;
        KASSERT(wpi_firmware_users == 0);
 +      if (wpi_firmware_image != NULL) {
 +              firmware_free(wpi_firmware_image, wpi_firmware_size);
 +              wpi_firmware_image = NULL;
 +              wpi_firmware_size = 0;
 +      }
        mutex_exit(&wpi_firmware_mutex);
        return error;
  }
 @@ -3092,7 +3105,8 @@ wpi_init(struct ifnet *ifp)
        WPI_WRITE(sc, WPI_UCODE_CLR, WPI_RADIO_OFF);
  
        if ((error = wpi_load_firmware(sc)) != 0) {
 -              aprint_error_dev(sc->sc_dev, "could not load firmware\n");
 +              /* wpi_load_firmware already prints a message on error */
 +              /*aprint_error_dev(sc->sc_dev, "could not load firmware\n");*/
                goto fail1;
        }
  
 
 -- 
 David A. Holland
 dholland%netbsd.org@localhost
 


Home | Main Index | Thread Index | Old Index