net: tcp: Fix memory leak with tcpackproc
authorBarret Rhoden <brho@cs.berkeley.edu>
Mon, 19 Jun 2017 18:40:01 +0000 (14:40 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Thu, 20 Jul 2017 12:19:46 +0000 (08:19 -0400)
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/src/net/tcp.c

index e9b3b0f..df551f6 100644 (file)
@@ -910,14 +910,15 @@ void tcpstart(struct conv *s, int mode)
 {
        Tcpctl *tcb;
        struct tcppriv *tpriv;
-       /* tcpackproc needs to free this if it ever exits */
-       char *kpname = kmalloc(KNAMELEN, MEM_WAIT);
+       char *kpname;
 
        tpriv = s->p->priv;
 
        if (tpriv->ackprocstarted == 0) {
                qlock(&tpriv->apl);
                if (tpriv->ackprocstarted == 0) {
+                       /* tcpackproc needs to free this if it ever exits */
+                       kpname = kmalloc(KNAMELEN, MEM_WAIT);
                        snprintf(kpname, KNAMELEN, "#I%dtcpack", s->p->f->dev);
                        ktask(kpname, tcpackproc, s->p);
                        tpriv->ackprocstarted = 1;