free(9) size for wi(4) @ USB

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

free(9) size for wi(4) @ USB

Martin Pieuchot
The driver already keeps track of the size of the allocated buffer, so
use it.

Diff is untested as I don't have a wi(4) @ USB.

ok?

Index: if_wi_usb.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/if_wi_usb.c,v
retrieving revision 1.68
diff -u -p -r1.68 if_wi_usb.c
--- if_wi_usb.c 24 Nov 2015 17:11:40 -0000 1.68
+++ if_wi_usb.c 8 Nov 2018 16:53:12 -0000
@@ -409,9 +409,10 @@ wi_usb_detach(struct device *self, int f
 
  while (sc->wi_usb_nummem) {
  sc->wi_usb_nummem--;
- if (sc->wi_usb_txmem[sc->wi_usb_nummem] != NULL)
- free(sc->wi_usb_txmem[sc->wi_usb_nummem], M_DEVBUF, 0);
+ free(sc->wi_usb_txmem[sc->wi_usb_nummem], M_DEVBUF,
+  sc->wi_usb_txmemsize[sc->wi_usb_nummem]);
  sc->wi_usb_txmem[sc->wi_usb_nummem] = NULL;
+ sc->wi_usb_txmemsize[sc->wi_usb_nummem] = 0;
  }
 
  if (sc->wi_usb_ep[WI_USB_ENDPT_INTR] != NULL) {
@@ -541,8 +542,10 @@ wi_cmd_usb(struct wi_softc *wsc, int cmd
  /* free alloc_nicmem regions */
  while (sc->wi_usb_nummem) {
  sc->wi_usb_nummem--;
- free(sc->wi_usb_txmem[sc->wi_usb_nummem], M_DEVBUF, 0);
+ free(sc->wi_usb_txmem[sc->wi_usb_nummem], M_DEVBUF,
+  sc->wi_usb_txmemsize[sc->wi_usb_nummem]);
  sc->wi_usb_txmem[sc->wi_usb_nummem] = NULL;
+ sc->wi_usb_txmemsize[sc->wi_usb_nummem] = 0;
  }
 
 #if 0