Hello, I worked a bit on umass(4) recently and had a diff to pass the umassbus_softc's real size to free so here it is. At some point I pondered about deleting the whole abstraction, as it would simplify the free'ing, for we only have one implementation (umass_scsi_softc, as atapi uses it too). But I figured it would be against the whole design of the umass driver, thoughts?
Index: usb/umass.c =================================================================== RCS file: /cvs/src/sys/dev/usb/umass.c,v retrieving revision 1.70 diff -u -p -r1.70 umass.c --- usb/umass.c 14 Mar 2015 03:38:50 -0000 1.70 +++ usb/umass.c 7 Dec 2015 15:40:15 -0000 @@ -651,7 +651,7 @@ umass_detach(struct device *self, int fl if (scbus != NULL) { if (scbus->sc_child != NULL) rv = config_detach(scbus->sc_child, flags); - free(scbus, M_DEVBUF, 0); + free(scbus, M_DEVBUF, scbus->sc_size); sc->bus = NULL; } Index: usb/umass_scsi.c =================================================================== RCS file: /cvs/src/sys/dev/usb/umass_scsi.c,v retrieving revision 1.42 diff -u -p -r1.42 umass_scsi.c --- usb/umass_scsi.c 14 Mar 2015 03:38:50 -0000 1.42 +++ usb/umass_scsi.c 7 Dec 2015 15:40:16 -0000 @@ -145,6 +145,7 @@ umass_scsi_setup(struct umass_softc *sc) struct umass_scsi_softc *scbus; scbus = malloc(sizeof(*scbus), M_DEVBUF, M_WAITOK | M_ZERO); + scbus->base.sc_size = sizeof(*scbus); sc->bus = (struct umassbus_softc *)scbus; Index: usb/umassvar.h =================================================================== RCS file: /cvs/src/sys/dev/usb/umassvar.h,v retrieving revision 1.14 diff -u -p -r1.14 umassvar.h --- usb/umassvar.h 6 Nov 2013 14:37:31 -0000 1.14 +++ usb/umassvar.h 7 Dec 2015 15:40:16 -0000 @@ -146,6 +146,7 @@ struct umass_wire_methods { struct umassbus_softc { struct device *sc_child; /* child device, for detach */ + size_t sc_size; }; /* the per device structure */