Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-6]: src/sys/kern Pull up following revision(s) (requested by njol...



details:   https://anonhg.NetBSD.org/src/rev/cdaa483fbd22
branches:  netbsd-6
changeset: 774339:cdaa483fbd22
user:      riz <riz%NetBSD.org@localhost>
date:      Fri Jul 20 23:10:06 2012 +0000

description:
Pull up following revision(s) (requested by njoly in ticket #423):
        sys/kern/uipc_syscalls.c: revision 1.156
Avoid kmem_alloc KASSERT for 0 byte allocation, when tracing processes
that use empty messages with sendmsg/recvmsg.

diffstat:

 sys/kern/uipc_syscalls.c |  21 +++++++++++----------
 1 files changed, 11 insertions(+), 10 deletions(-)

diffs (72 lines):

diff -r 0044afc8bc7b -r cdaa483fbd22 sys/kern/uipc_syscalls.c
--- a/sys/kern/uipc_syscalls.c  Fri Jul 20 23:07:58 2012 +0000
+++ b/sys/kern/uipc_syscalls.c  Fri Jul 20 23:10:06 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uipc_syscalls.c,v 1.154 2012/01/25 16:56:13 christos Exp $     */
+/*     $NetBSD: uipc_syscalls.c,v 1.154.2.1 2012/07/20 23:10:06 riz Exp $      */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.154 2012/01/25 16:56:13 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.154.2.1 2012/07/20 23:10:06 riz Exp $");
 
 #include "opt_pipe.h"
 
@@ -605,7 +605,7 @@
                }
        }
 
-       if (ktrpoint(KTR_GENIO)) {
+       if (ktrpoint(KTR_GENIO) && iovsz > 0) {
                ktriov = kmem_alloc(iovsz, KM_SLEEP);
                memcpy(ktriov, auio.uio_iov, iovsz);
        }
@@ -640,9 +640,10 @@
                *retsize = len - auio.uio_resid;
 
 bad:
-       if (ktriov != NULL) {
+       if (ktrpoint(KTR_GENIO)) {
                ktrgeniov(s, UIO_WRITE, ktriov, *retsize, error);
-               kmem_free(ktriov, iovsz);
+               if (ktriov != NULL)
+                       kmem_free(ktriov, iovsz);
        }
 
        if (iov != aiov)
@@ -826,7 +827,7 @@
 do_sys_recvmsg(struct lwp *l, int s, struct msghdr *mp, struct mbuf **from,
     struct mbuf **control, register_t *retsize)
 {
-       struct iovec    aiov[UIO_SMALLIOV], *iov = aiov, *tiov, *ktriov;
+       struct iovec    aiov[UIO_SMALLIOV], *iov = aiov, *tiov, *ktriov = NULL;
        struct socket   *so;
        struct uio      auio;
        size_t          len, iovsz;
@@ -880,8 +881,7 @@
                }
        }
 
-       ktriov = NULL;
-       if (ktrpoint(KTR_GENIO)) {
+       if (ktrpoint(KTR_GENIO) && iovsz > 0) {
                ktriov = kmem_alloc(iovsz, KM_SLEEP);
                memcpy(ktriov, auio.uio_iov, iovsz);
        }
@@ -897,9 +897,10 @@
                /* Some data transferred */
                error = 0;
 
-       if (ktriov != NULL) {
+       if (ktrpoint(KTR_GENIO)) {
                ktrgeniov(s, UIO_READ, ktriov, len, error);
-               kmem_free(ktriov, iovsz);
+               if (ktriov != NULL)
+                       kmem_free(ktriov, iovsz);
        }
 
        if (error != 0) {



Home | Main Index | Thread Index | Old Index