kernel/netgraph7: Replace usage of MALLOC/FREE with kmalloc/kfree here too.
[dragonfly.git] / sys / netgraph7 / ng_async.c
index d53f824..c9e7eed 100644 (file)
@@ -184,23 +184,24 @@ nga_constructor(node_p node)
 {
        sc_p sc;
 
-       MALLOC(sc, sc_p, sizeof(*sc), M_NETGRAPH_ASYNC, M_WAITOK | M_NULLOK | M_ZERO);
+       sc = kmalloc(sizeof(*sc), M_NETGRAPH_ASYNC,
+                    M_WAITOK | M_NULLOK | M_ZERO);
        if (sc == NULL)
                return (ENOMEM);
        sc->amode = MODE_HUNT;
        sc->cfg.accm = ~0;
        sc->cfg.amru = NG_ASYNC_DEFAULT_MRU;
        sc->cfg.smru = NG_ASYNC_DEFAULT_MRU;
-       MALLOC(sc->abuf, u_char *,
-           ASYNC_BUF_SIZE(sc->cfg.smru), M_NETGRAPH_ASYNC, M_WAITOK | M_NULLOK);
+       sc->abuf = kmalloc(ASYNC_BUF_SIZE(sc->cfg.smru), M_NETGRAPH_ASYNC,
+                          M_WAITOK | M_NULLOK);
        if (sc->abuf == NULL)
                goto fail;
-       MALLOC(sc->sbuf, u_char *,
-           SYNC_BUF_SIZE(sc->cfg.amru), M_NETGRAPH_ASYNC, M_WAITOK | M_NULLOK);
+       sc->sbuf = kmalloc(SYNC_BUF_SIZE(sc->cfg.amru), M_NETGRAPH_ASYNC,
+                          M_WAITOK | M_NULLOK);
        if (sc->sbuf == NULL) {
-               FREE(sc->abuf, M_NETGRAPH_ASYNC);
+               kfree(sc->abuf, M_NETGRAPH_ASYNC);
 fail:
-               FREE(sc, M_NETGRAPH_ASYNC);
+               kfree(sc, M_NETGRAPH_ASYNC);
                return (ENOMEM);
        }
        NG_NODE_SET_PRIVATE(node, sc);
@@ -299,19 +300,21 @@ nga_rcvmsg(node_p node, item_p item, hook_p lasthook)
                                ERROUT(EINVAL);
                        cfg->enabled = !!cfg->enabled;  /* normalize */
                        if (cfg->smru > sc->cfg.smru) { /* reallocate buffer */
-                               MALLOC(buf, u_char *, ASYNC_BUF_SIZE(cfg->smru),
-                                   M_NETGRAPH_ASYNC, M_WAITOK | M_NULLOK);
+                               buf = kmalloc(ASYNC_BUF_SIZE(cfg->smru),
+                                             M_NETGRAPH_ASYNC,
+                                             M_WAITOK | M_NULLOK);
                                if (!buf)
                                        ERROUT(ENOMEM);
-                               FREE(sc->abuf, M_NETGRAPH_ASYNC);
+                               kfree(sc->abuf, M_NETGRAPH_ASYNC);
                                sc->abuf = buf;
                        }
                        if (cfg->amru > sc->cfg.amru) { /* reallocate buffer */
-                               MALLOC(buf, u_char *, SYNC_BUF_SIZE(cfg->amru),
-                                   M_NETGRAPH_ASYNC, M_WAITOK | M_NULLOK);
+                               buf = kmalloc(SYNC_BUF_SIZE(cfg->amru),
+                                             M_NETGRAPH_ASYNC,
+                                             M_WAITOK | M_NULLOK);
                                if (!buf)
                                        ERROUT(ENOMEM);
-                               FREE(sc->sbuf, M_NETGRAPH_ASYNC);
+                               kfree(sc->sbuf, M_NETGRAPH_ASYNC);
                                sc->sbuf = buf;
                                sc->amode = MODE_HUNT;
                                sc->slen = 0;
@@ -350,10 +353,10 @@ nga_shutdown(node_p node)
 {
        const sc_p sc = NG_NODE_PRIVATE(node);
 
-       FREE(sc->abuf, M_NETGRAPH_ASYNC);
-       FREE(sc->sbuf, M_NETGRAPH_ASYNC);
+       kfree(sc->abuf, M_NETGRAPH_ASYNC);
+       kfree(sc->sbuf, M_NETGRAPH_ASYNC);
        bzero(sc, sizeof(*sc));
-       FREE(sc, M_NETGRAPH_ASYNC);
+       kfree(sc, M_NETGRAPH_ASYNC);
        NG_NODE_SET_PRIVATE(node, NULL);
        NG_NODE_UNREF(node);
        return (0);