]> Zhao Yanbai Git Server - minix.git/commitdiff
Fixed two memory leaks.
authorPhilip Homburg <philip@cs.vu.nl>
Thu, 16 Feb 2006 14:13:36 +0000 (14:13 +0000)
committerPhilip Homburg <philip@cs.vu.nl>
Thu, 16 Feb 2006 14:13:36 +0000 (14:13 +0000)
servers/inet/generic/arp.c
servers/inet/generic/eth.c
servers/inet/generic/tcp.c

index 84ea087b07882ad528cfb20a1d0ea67fc16f7d51..536d58ef0cecfbde02d802b42bf57f99d17a13f4 100644 (file)
@@ -1340,7 +1340,12 @@ PRIVATE void arp_bufcheck()
 
        for (i= 0, arp_port= arp_port_table; i<eth_conf_nr; i++, arp_port++)
        {
-               for (pack= arp_port->ap_reqlist; pack;
+               for (pack= arp_port->ap_reclist; pack;
+                       pack= pack->acc_ext_link)
+               {
+                       bf_check_acc(pack);
+               }
+               for (pack= arp_port->ap_sendlist; pack;
                        pack= pack->acc_ext_link)
                {
                        bf_check_acc(pack);
index 363aea6e48f5dd9a90098d96ec5d60c6261443b0..8a118b0a62b2dfa35193e9ffe79569261487d069 100644 (file)
@@ -335,9 +335,6 @@ ioreq_t req;
                                return NW_OK;
                        }
 
-                       acc= bf_memreq(sizeof(nwio_ethstat_t));
-                       compare (bf_bufsize(acc), ==, sizeof(*ethstat));
-
                        if (!(eth_port->etp_flags & EPF_GOT_ADDR))
                        {
                                printf(
@@ -349,6 +346,9 @@ ioreq_t req;
                                return NW_SUSPEND;
                        }
 
+                       acc= bf_memreq(sizeof(nwio_ethstat_t));
+                       compare (bf_bufsize(acc), ==, sizeof(*ethstat));
+
                        ethstat= (nwio_ethstat_t *)ptr2acc_data(acc);
                        ethstat->nwes_addr= eth_port->etp_ethaddr;
 
index c623674b200161958593168bc2fee638a8e99898..f7cee644f525bd05343ed4da48f77e085d340cbc 100644 (file)
@@ -2269,12 +2269,14 @@ tcp_fd_t *tcp_fd;
                sizeof(*cookiep), TRUE);
        if (!data)
                return EFAULT;
+
        data= bf_packIffLess(data, sizeof(*cookiep));
        cookiep= (tcp_cookie_t *)ptr2acc_data(data);
 
        dst_nr= cookiep->tc_ref;
        if (dst_nr < 0 || dst_nr >= TCP_FD_NR)
        {
+               bf_afree(data); data= NULL;
                printf("tcp_acceptto: bad fd %d\n", dst_nr);
                tcp_reply_ioctl(tcp_fd, EINVAL);
                return NW_OK;
@@ -2285,6 +2287,7 @@ tcp_fd_t *tcp_fd;
                dst_fd->tf_conn != NULL ||
                !(dst_fd->tf_flags & TFF_COOKIE))
        {
+               bf_afree(data); data= NULL;
                printf("tcp_acceptto: bad flags 0x%x or conn %p for fd %d\n",
                        dst_fd->tf_flags, dst_fd->tf_conn, dst_nr);
                tcp_reply_ioctl(tcp_fd, EINVAL);
@@ -2292,10 +2295,13 @@ tcp_fd_t *tcp_fd;
        }
        if (memcmp(cookiep, &dst_fd->tf_cookie, sizeof(*cookiep)) != 0)
        {
+               bf_afree(data); data= NULL;
                printf("tcp_acceptto: bad cookie\n");
                return NW_OK;
        }
 
+       bf_afree(data); data= NULL;
+
        /* Move connection */
        tcp_fd->tf_listenq[i]= NULL;
        tcp_conn->tc_fd= dst_fd;