1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-14 10:09:48 +00:00

Thanks for Andrew Gallatin pointing out that freeing contigmalloc'd

items via free is bad.
This commit is contained in:
Matt Jacob 2000-07-09 00:18:21 +00:00
parent 480a6f5ceb
commit 6e95418137
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=62832

View File

@ -698,6 +698,8 @@ wx_dring_setup(sc)
return (-1); return (-1);
} }
if (((u_long)sc->rdescriptors) & 0xfff) { if (((u_long)sc->rdescriptors) & 0xfff) {
contigfree(sc->rdescriptors, len, M_DEVBUF);
sc->rdescriptors = NULL;
printf("%s: rcv descriptors not 4KB aligned\n", sc->wx_name); printf("%s: rcv descriptors not 4KB aligned\n", sc->wx_name);
return (-1); return (-1);
} }
@ -707,10 +709,16 @@ wx_dring_setup(sc)
sc->tdescriptors = (wxtd_t *) sc->tdescriptors = (wxtd_t *)
contigmalloc(len, M_DEVBUF, M_NOWAIT, 0, ~0, 4096, 0); contigmalloc(len, M_DEVBUF, M_NOWAIT, 0, ~0, 4096, 0);
if (sc->tdescriptors == NULL) { if (sc->tdescriptors == NULL) {
contigfree(sc->rdescriptors,
sizeof (wxrd_t) * WX_MAX_RDESC, M_DEVBUF);
sc->rdescriptors = NULL;
printf("%s: could not allocate xmt descriptors\n", sc->wx_name); printf("%s: could not allocate xmt descriptors\n", sc->wx_name);
return (-1); return (-1);
} }
if (((u_long)sc->tdescriptors) & 0xfff) { if (((u_long)sc->tdescriptors) & 0xfff) {
contigfree(sc->rdescriptors,
sizeof (wxrd_t) * WX_MAX_RDESC, M_DEVBUF);
sc->rdescriptors = NULL;
printf("%s: xmt descriptors not 4KB aligned\n", sc->wx_name); printf("%s: xmt descriptors not 4KB aligned\n", sc->wx_name);
return (-1); return (-1);
} }
@ -723,11 +731,13 @@ wx_dring_teardown(sc)
wx_softc_t *sc; wx_softc_t *sc;
{ {
if (sc->rdescriptors) { if (sc->rdescriptors) {
WXFREE(sc->rdescriptors); contigfree(sc->rdescriptors,
sizeof (wxrd_t) * WX_MAX_RDESC, M_DEVBUF);
sc->rdescriptors = NULL; sc->rdescriptors = NULL;
} }
if (sc->tdescriptors) { if (sc->tdescriptors) {
WXFREE(sc->tdescriptors); contigfree(sc->tdescriptors,
sizeof (wxtd_t) * WX_MAX_TDESC, M_DEVBUF);
sc->tdescriptors = NULL; sc->tdescriptors = NULL;
} }
} }