Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb Pass the correct length to firmware_free. The co...



details:   https://anonhg.NetBSD.org/src/rev/f5de31f2a4d5
branches:  trunk
changeset: 805657:f5de31f2a4d5
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sun Jan 11 14:19:09 2015 +0000

description:
Pass the correct length to firmware_free. The code previously did
len = firmware_get_size(..) and then used len as a counter while loading
firmware. The result was that in the success path, len = 0. This commit
introduces a new "fwlen" (const) to store the firmware size, and passes it
to firmware_free instead of "len".

diffstat:

 sys/dev/usb/if_urtwn.c |  10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diffs (45 lines):

diff -r c38a64135c98 -r f5de31f2a4d5 sys/dev/usb/if_urtwn.c
--- a/sys/dev/usb/if_urtwn.c    Sun Jan 11 13:40:22 2015 +0000
+++ b/sys/dev/usb/if_urtwn.c    Sun Jan 11 14:19:09 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_urtwn.c,v 1.35 2015/01/07 07:05:48 ozaki-r Exp $    */
+/*     $NetBSD: if_urtwn.c,v 1.36 2015/01/11 14:19:09 jmcneill Exp $   */
 /*     $OpenBSD: if_urtwn.c,v 1.20 2011/11/26 06:39:33 ckuethe Exp $   */
 
 /*-
@@ -23,7 +23,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.35 2015/01/07 07:05:48 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.36 2015/01/11 14:19:09 jmcneill Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -3072,7 +3072,7 @@
                    error);
                return (error);
        }
-       len = firmware_get_size(fwh);
+       const size_t fwlen = len = firmware_get_size(fwh);
        fw = firmware_malloc(len);
        if (fw == NULL) {
                aprint_error_dev(sc->sc_dev,
@@ -3085,7 +3085,7 @@
        if (error != 0) {
                aprint_error_dev(sc->sc_dev,
                    "failed to read firmware (error %d)\n", error);
-               firmware_free(fw, len);
+               firmware_free(fw, fwlen);
                return (error);
        }
 
@@ -3175,7 +3175,7 @@
                goto fail;
        }
  fail:
-       firmware_free(fw, len);
+       firmware_free(fw, fwlen);
        return (error);
 }
 



Home | Main Index | Thread Index | Old Index