CVS commit: src/sys/ufs/ffs
Module Name:src Committed By: dholland Date: Thu Jul 10 06:02:40 UTC 2014 Modified Files: src/sys/ufs/ffs: ffs_snapshot.c Log Message: Use an explicit compare to 0 for an immediate error result, not !. Using ! is perfectly clear on variables like error or result, but directly on a function call it tends to look like a mistake. To generate a diff of this commit: cvs rdiff -u -r1.135 -r1.136 src/sys/ufs/ffs/ffs_snapshot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ffs/ffs_snapshot.c diff -u src/sys/ufs/ffs/ffs_snapshot.c:1.135 src/sys/ufs/ffs/ffs_snapshot.c:1.136 --- src/sys/ufs/ffs/ffs_snapshot.c:1.135 Fri May 30 08:40:09 2014 +++ src/sys/ufs/ffs/ffs_snapshot.c Thu Jul 10 06:02:40 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_snapshot.c,v 1.135 2014/05/30 08:40:09 hannken Exp $ */ +/* $NetBSD: ffs_snapshot.c,v 1.136 2014/07/10 06:02:40 dholland Exp $ */ /* * Copyright 2000 Marshall Kirk McKusick. All Rights Reserved. @@ -38,7 +38,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ffs_snapshot.c,v 1.135 2014/05/30 08:40:09 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: ffs_snapshot.c,v 1.136 2014/07/10 06:02:40 dholland Exp $); #if defined(_KERNEL_OPT) #include opt_ffs.h @@ -399,7 +399,7 @@ out: #endif } if (error) { - if (!UFS_WAPBL_BEGIN(mp)) { + if (UFS_WAPBL_BEGIN(mp) == 0) { (void) ffs_truncate(vp, (off_t)0, 0, NOCRED); UFS_WAPBL_END(mp); }
CVS commit: src/sys/arch/sparc64
Module Name:src Committed By: jdc Date: Thu Jul 10 06:24:02 UTC 2014 Modified Files: src/sys/arch/sparc64/include: param.h src/sys/arch/sparc64/sparc64: pmap.c Log Message: Increase maximum MSGBUFSIZE to 248k. While here, remove 2 sparc(32)-only entries (from mrg@). To generate a diff of this commit: cvs rdiff -u -r1.53 -r1.54 src/sys/arch/sparc64/include/param.h cvs rdiff -u -r1.288 -r1.289 src/sys/arch/sparc64/sparc64/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/sparc64/include/param.h diff -u src/sys/arch/sparc64/include/param.h:1.53 src/sys/arch/sparc64/include/param.h:1.54 --- src/sys/arch/sparc64/include/param.h:1.53 Fri Feb 21 18:00:09 2014 +++ src/sys/arch/sparc64/include/param.h Thu Jul 10 06:24:02 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.53 2014/02/21 18:00:09 palle Exp $ */ +/* $NetBSD: param.h,v 1.54 2014/07/10 06:24:02 jdc Exp $ */ /* * Copyright (c) 1992, 1993 @@ -168,13 +168,12 @@ extern int nbpg, pgofset, pgshift; #define _MAXNBPG 8192 /* fixed VAs, independent of actual NBPG */ -#define AUXREG_VA ( KERNEND + _MAXNBPG) /* 1 page REDZONE */ -#define TMPMAP_VA (AUXREG_VA + _MAXNBPG) -#define MSGBUF_VA (TMPMAP_VA + _MAXNBPG) +#define MSGBUF_VA ( KERNEND + _MAXNBPG) /* 1 page REDZONE */ /* + * Maximum message buffer size is 248k. * Here's the location of the interrupt stack and CPU structure. */ -#define INTSTACK ( KERNEND + 8*_MAXNBPG) +#define INTSTACK ( KERNEND + 32*_MAXNBPG) #define EINTSTACK ( INTSTACK + 4*_MAXNBPG) #define CPUINFO_VA (EINTSTACK ) #define PANICSTACK ( INTSTACK + 8*_MAXNBPG) @@ -197,7 +196,13 @@ extern int nbpg, pgofset, pgshift; #define MCLBYTES (1 MCLSHIFT) /* size of a m_buf cluster */ -#define MSGBUFSIZE NBPG +#if !defined (MSGBUFSIZE) /* options MSGBUFSIZE=integer */ +#define MSGBUFSIZE 4 * NBPG +#else +#if INTSTACK - MSGBUF_VA - MSGBUFSIZE 0 +#error MSGBUFSIZE is too large +#endif +#endif /* * Minimum size of the kernel kmem_arena in PAGE_SIZE-sized Index: src/sys/arch/sparc64/sparc64/pmap.c diff -u src/sys/arch/sparc64/sparc64/pmap.c:1.288 src/sys/arch/sparc64/sparc64/pmap.c:1.289 --- src/sys/arch/sparc64/sparc64/pmap.c:1.288 Thu Jun 5 19:47:24 2014 +++ src/sys/arch/sparc64/sparc64/pmap.c Thu Jul 10 06:24:02 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.288 2014/06/05 19:47:24 palle Exp $ */ +/* $NetBSD: pmap.c,v 1.289 2014/07/10 06:24:02 jdc Exp $ */ /* * * Copyright (C) 1996-1999 Eduardo Horvath. @@ -26,7 +26,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: pmap.c,v 1.288 2014/06/05 19:47:24 palle Exp $); +__KERNEL_RCSID(0, $NetBSD: pmap.c,v 1.289 2014/07/10 06:24:02 jdc Exp $); #undef NO_VCACHE /* Don't forget the locked TLB in dostart */ #define HWREF @@ -742,8 +742,7 @@ pmap_bootstrap(u_long kernelstart, u_lon * Get hold or the message buffer. */ msgbufp = (struct kern_msgbuf *)(vaddr_t)MSGBUF_VA; -/* X -- increase msgbufsiz for uvmhist printing */ - msgbufsiz = 4*PAGE_SIZE /* round_page(sizeof(struct msgbuf)) */; + msgbufsiz = MSGBUFSIZE; BDPRINTF(PDB_BOOT, (Trying to allocate msgbuf at %lx, size %lx\n, (long)msgbufp, (long)msgbufsiz)); if ((long)msgbufp !=
CVS commit: src/sys/ufs/ffs
Module Name:src Committed By: dholland Date: Thu Jul 10 06:27:15 UTC 2014 Modified Files: src/sys/ufs/ffs: ffs_wapbl.c Log Message: Fix unchecked UFS_WAPBL_BEGIN. Coverity 975226. Unfortunately it looks like all we can do on error here is printf. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/ufs/ffs/ffs_wapbl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ffs/ffs_wapbl.c diff -u src/sys/ufs/ffs/ffs_wapbl.c:1.25 src/sys/ufs/ffs/ffs_wapbl.c:1.26 --- src/sys/ufs/ffs/ffs_wapbl.c:1.25 Fri Oct 25 11:35:55 2013 +++ src/sys/ufs/ffs/ffs_wapbl.c Thu Jul 10 06:27:15 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_wapbl.c,v 1.25 2013/10/25 11:35:55 martin Exp $ */ +/* $NetBSD: ffs_wapbl.c,v 1.26 2014/07/10 06:27:15 dholland Exp $ */ /*- * Copyright (c) 2003,2006,2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ffs_wapbl.c,v 1.25 2013/10/25 11:35:55 martin Exp $); +__KERNEL_RCSID(0, $NetBSD: ffs_wapbl.c,v 1.26 2014/07/10 06:27:15 dholland Exp $); #define WAPBL_INTERNAL @@ -147,9 +147,16 @@ ffs_wapbl_replay_finish(struct mount *mp * initialized in ufs_makeinode. If so, just dallocate them. */ if (ip-i_mode == 0) { - UFS_WAPBL_BEGIN(mp); - ffs_vfree(vp, ip-i_number, wr-wr_inodes[i].wr_imode); - UFS_WAPBL_END(mp); + error = UFS_WAPBL_BEGIN(mp); + if (error) { +printf(ffs_wapbl_replay_finish: +unable to cleanup inode % PRIu32 \n, +wr-wr_inodes[i].wr_inumber); + } else { +ffs_vfree(vp, ip-i_number, +wr-wr_inodes[i].wr_imode); +UFS_WAPBL_END(mp); + } } vput(vp); }
CVS commit: src/lib/librumpuser
Module Name:src Committed By: justin Date: Thu Jul 10 08:17:43 UTC 2014 Modified Files: src/lib/librumpuser: rumpuser.c Log Message: Reinstate include of netdb.h, needed on some cross builds To generate a diff of this commit: cvs rdiff -u -r1.60 -r1.61 src/lib/librumpuser/rumpuser.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/librumpuser/rumpuser.c diff -u src/lib/librumpuser/rumpuser.c:1.60 src/lib/librumpuser/rumpuser.c:1.61 --- src/lib/librumpuser/rumpuser.c:1.60 Wed Jul 9 23:41:40 2014 +++ src/lib/librumpuser/rumpuser.c Thu Jul 10 08:17:43 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: rumpuser.c,v 1.60 2014/07/09 23:41:40 justin Exp $ */ +/* $NetBSD: rumpuser.c,v 1.61 2014/07/10 08:17:43 justin Exp $ */ /* * Copyright (c) 2007-2010 Antti Kantee. All Rights Reserved. @@ -28,7 +28,7 @@ #include rumpuser_port.h #if !defined(lint) -__RCSID($NetBSD: rumpuser.c,v 1.60 2014/07/09 23:41:40 justin Exp $); +__RCSID($NetBSD: rumpuser.c,v 1.61 2014/07/10 08:17:43 justin Exp $); #endif /* !lint */ #include sys/stat.h @@ -38,6 +38,7 @@ __RCSID($NetBSD: rumpuser.c,v 1.60 2014 #include assert.h #include errno.h #include fcntl.h +#include netdb.h #include signal.h #include stdarg.h #include stdint.h
CVS commit: src/sys/netinet
Module Name:src Committed By: rmind Date: Thu Jul 10 14:05:19 UTC 2014 Modified Files: src/sys/netinet: tcp_usrreq.c Log Message: tcp_accept: simplify a little. To generate a diff of this commit: cvs rdiff -u -r1.186 -r1.187 src/sys/netinet/tcp_usrreq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/netinet/tcp_usrreq.c diff -u src/sys/netinet/tcp_usrreq.c:1.186 src/sys/netinet/tcp_usrreq.c:1.187 --- src/sys/netinet/tcp_usrreq.c:1.186 Wed Jul 9 14:41:42 2014 +++ src/sys/netinet/tcp_usrreq.c Thu Jul 10 14:05:19 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_usrreq.c,v 1.186 2014/07/09 14:41:42 rtr Exp $ */ +/* $NetBSD: tcp_usrreq.c,v 1.187 2014/07/10 14:05:19 rmind Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -99,7 +99,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: tcp_usrreq.c,v 1.186 2014/07/09 14:41:42 rtr Exp $); +__KERNEL_RCSID(0, $NetBSD: tcp_usrreq.c,v 1.187 2014/07/10 14:05:19 rmind Exp $); #include opt_inet.h #include opt_ipsec.h @@ -948,20 +948,6 @@ tcp_accept(struct socket *so, struct mbu { return EINVAL; } -#ifdef INET - if (inp) { - tp = intotcpcb(inp); - /* WHAT IF TP IS 0? */ - ostate = tcp_debug_capture(tp, PRU_ACCEPT); - } -#endif -#ifdef INET6 - if (in6p) { - tp = in6totcpcb(in6p); - /* WHAT IF TP IS 0? */ - ostate = tcp_debug_capture(tp, PRU_ACCEPT); - } -#endif /* * Accept a connection. Essentially all the work is @@ -969,16 +955,22 @@ tcp_accept(struct socket *so, struct mbu * of the peer, storing through addr. */ #ifdef INET - if (inp) + if (inp) { + tp = intotcpcb(inp); + KASSERT(tp != NULL); + ostate = tcp_debug_capture(tp, PRU_ACCEPT); in_setpeeraddr(inp, nam); + } #endif #ifdef INET6 - if (in6p) + if (in6p) { + tp = in6totcpcb(in6p); + KASSERT(tp != NULL); + ostate = tcp_debug_capture(tp, PRU_ACCEPT); in6_setpeeraddr(in6p, nam); + } #endif - tcp_debug_trace(so, tp, ostate, PRU_ACCEPT); - return 0; }
CVS commit: src/sys/kern
Module Name:src Committed By: christos Date: Thu Jul 10 15:00:28 UTC 2014 Modified Files: src/sys/kern: kern_fileassoc.c Log Message: table can't be NULL here. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/sys/kern/kern_fileassoc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_fileassoc.c diff -u src/sys/kern/kern_fileassoc.c:1.35 src/sys/kern/kern_fileassoc.c:1.36 --- src/sys/kern/kern_fileassoc.c:1.35 Sat Jan 21 22:48:51 2012 +++ src/sys/kern/kern_fileassoc.c Thu Jul 10 11:00:28 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_fileassoc.c,v 1.35 2012/01/22 03:48:51 rmind Exp $ */ +/* $NetBSD: kern_fileassoc.c,v 1.36 2014/07/10 15:00:28 christos Exp $ */ /*- * Copyright (c) 2006 Elad Efrat e...@netbsd.org @@ -28,7 +28,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: kern_fileassoc.c,v 1.35 2012/01/22 03:48:51 rmind Exp $); +__KERNEL_RCSID(0, $NetBSD: kern_fileassoc.c,v 1.36 2014/07/10 15:00:28 christos Exp $); #include opt_fileassoc.h @@ -525,6 +525,7 @@ fileassoc_file_delete(struct vnode *vp) file_free(faf); tbl = fileassoc_table_lookup(vp-v_mount); + KASSERT(tbl != NULL); --(tbl-tbl_nused); /* XXX gc? */ KERNEL_UNLOCK_ONE(NULL);
CVS commit: src/sys/ufs/ffs
Module Name:src Committed By: christos Date: Thu Jul 10 15:15:54 UTC 2014 Modified Files: src/sys/ufs/ffs: ffs_wapbl.c Log Message: CID 975226: hande error from UFS_WAPBL_BEGIN To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/ufs/ffs/ffs_wapbl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ffs/ffs_wapbl.c diff -u src/sys/ufs/ffs/ffs_wapbl.c:1.26 src/sys/ufs/ffs/ffs_wapbl.c:1.27 --- src/sys/ufs/ffs/ffs_wapbl.c:1.26 Thu Jul 10 02:27:15 2014 +++ src/sys/ufs/ffs/ffs_wapbl.c Thu Jul 10 11:15:54 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_wapbl.c,v 1.26 2014/07/10 06:27:15 dholland Exp $ */ +/* $NetBSD: ffs_wapbl.c,v 1.27 2014/07/10 15:15:54 christos Exp $ */ /*- * Copyright (c) 2003,2006,2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ffs_wapbl.c,v 1.26 2014/07/10 06:27:15 dholland Exp $); +__KERNEL_RCSID(0, $NetBSD: ffs_wapbl.c,v 1.27 2014/07/10 15:15:54 christos Exp $); #define WAPBL_INTERNAL @@ -351,20 +351,18 @@ ffs_wapbl_start(struct mount *mp) #endif if ((fs-fs_flags FS_DOWAPBL) == 0) { -UFS_WAPBL_BEGIN(mp); +if ((error = UFS_WAPBL_BEGIN(mp)) != 0) + goto out; fs-fs_flags |= FS_DOWAPBL; error = ffs_sbupdate(ump, MNT_WAIT); if (error) { UFS_WAPBL_END(mp); - ffs_wapbl_stop(mp, MNT_FORCE); - return error; + goto out; } UFS_WAPBL_END(mp); error = wapbl_flush(mp-mnt_wapbl, 1); -if (error) { - ffs_wapbl_stop(mp, MNT_FORCE); - return error; -} +if (error) + goto out; } } else if (fs-fs_flags FS_DOWAPBL) { fs-fs_fmod = 1; @@ -391,6 +389,9 @@ ffs_wapbl_start(struct mount *mp) } return 0; +out: + ffs_wapbl_stop(mp, MNT_FORCE); + return error; } int
CVS commit: src/sys/dev/ic
Module Name:src Committed By: christos Date: Thu Jul 10 15:26:30 UTC 2014 Modified Files: src/sys/dev/ic: smc91cxx.c Log Message: add missing fallthrough To generate a diff of this commit: cvs rdiff -u -r1.86 -r1.87 src/sys/dev/ic/smc91cxx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ic/smc91cxx.c diff -u src/sys/dev/ic/smc91cxx.c:1.86 src/sys/dev/ic/smc91cxx.c:1.87 --- src/sys/dev/ic/smc91cxx.c:1.86 Sun Sep 8 10:27:39 2013 +++ src/sys/dev/ic/smc91cxx.c Thu Jul 10 11:26:30 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: smc91cxx.c,v 1.86 2013/09/08 14:27:39 chs Exp $ */ +/* $NetBSD: smc91cxx.c,v 1.87 2014/07/10 15:26:30 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: smc91cxx.c,v 1.86 2013/09/08 14:27:39 chs Exp $); +__KERNEL_RCSID(0, $NetBSD: smc91cxx.c,v 1.87 2014/07/10 15:26:30 christos Exp $); #include opt_inet.h @@ -331,6 +331,7 @@ smc91cxx_attach(struct smc91cxx_softc *s * even if the PHY does. */ miicapabilities = ~(BMSR_100TXFDX | BMSR_10TFDX); + /*FALLTHROUGH*/ case CHIP_91100FD: case CHIP_91C111: if (tmp CR_MII_SELECT) {
CVS commit: src/sys/net
Module Name:src Committed By: christos Date: Thu Jul 10 15:32:10 UTC 2014 Modified Files: src/sys/net: bpf.c Log Message: initialize args the same way we do in filter. To generate a diff of this commit: cvs rdiff -u -r1.183 -r1.184 src/sys/net/bpf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/bpf.c diff -u src/sys/net/bpf.c:1.183 src/sys/net/bpf.c:1.184 --- src/sys/net/bpf.c:1.183 Tue Jun 24 06:53:30 2014 +++ src/sys/net/bpf.c Thu Jul 10 11:32:09 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: bpf.c,v 1.183 2014/06/24 10:53:30 alnsn Exp $ */ +/* $NetBSD: bpf.c,v 1.184 2014/07/10 15:32:09 christos Exp $ */ /* * Copyright (c) 1990, 1991, 1993 @@ -39,7 +39,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: bpf.c,v 1.183 2014/06/24 10:53:30 alnsn Exp $); +__KERNEL_RCSID(0, $NetBSD: bpf.c,v 1.184 2014/07/10 15:32:09 christos Exp $); #if defined(_KERNEL_OPT) #include opt_bpf.h @@ -1388,16 +1388,18 @@ bpf_deliver(struct bpf_if *bp, void *(*c void *pkt, u_int pktlen, u_int buflen, const bool rcv) { struct timespec ts; - bpf_args_t args; + bpf_args_t args = { + .pkt = (const uint8_t *)pkt, + .wirelen = pktlen, + .buflen = buflen, + .mem = NULL, + .arg = NULL + }; struct bpf_d *d; const bpf_ctx_t *bc = NULL; bool gottime = false; - args.pkt = (const uint8_t *)pkt; - args.wirelen = pktlen; - args.buflen = buflen; - /* * Note that the IPL does not have to be raised at this point. * The only problem that could arise here is that if two different
CVS commit: src/sys/kern
Module Name:src Committed By: maxv Date: Thu Jul 10 19:12:07 UTC 2014 Modified Files: src/sys/kern: sys_module.c Log Message: Fix a user-controlled memory allocation. kmem_alloc(0) will panic the system. ok christos@ To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/kern/sys_module.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/sys_module.c diff -u src/sys/kern/sys_module.c:1.14 src/sys/kern/sys_module.c:1.15 --- src/sys/kern/sys_module.c:1.14 Tue Aug 7 01:19:05 2012 +++ src/sys/kern/sys_module.c Thu Jul 10 19:12:07 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: sys_module.c,v 1.14 2012/08/07 01:19:05 jnemeth Exp $ */ +/* $NetBSD: sys_module.c,v 1.15 2014/07/10 19:12:07 maxv Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: sys_module.c,v 1.14 2012/08/07 01:19:05 jnemeth Exp $); +__KERNEL_RCSID(0, $NetBSD: sys_module.c,v 1.15 2014/07/10 19:12:07 maxv Exp $); #include sys/param.h #include sys/systm.h @@ -46,6 +46,11 @@ __KERNEL_RCSID(0, $NetBSD: sys_module.c #include opt_modular.h +/* + * Arbitrary limit to avoid DoS for excessive memory allocation. + */ +#define MAXPROPSLEN 4096 + static int handle_modctl_load(modctl_load_t *ml) { @@ -67,7 +72,12 @@ handle_modctl_load(modctl_load_t *ml) goto out2; if (ml-ml_props != NULL) { + if (ml-ml_propslen MAXPROPSLEN) { + error = ENOMEM; + goto out2; + } propslen = ml-ml_propslen + 1; + props = (char *)kmem_alloc(propslen, KM_SLEEP); if (props == NULL) { error = ENOMEM;
CVS commit: src/sys/kern
Module Name:src Committed By: maxv Date: Thu Jul 10 19:21:46 UTC 2014 Modified Files: src/sys/kern: sys_module.c Log Message: Simplify a bit To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/kern/sys_module.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/sys_module.c diff -u src/sys/kern/sys_module.c:1.15 src/sys/kern/sys_module.c:1.16 --- src/sys/kern/sys_module.c:1.15 Thu Jul 10 19:12:07 2014 +++ src/sys/kern/sys_module.c Thu Jul 10 19:21:46 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: sys_module.c,v 1.15 2014/07/10 19:12:07 maxv Exp $ */ +/* $NetBSD: sys_module.c,v 1.16 2014/07/10 19:21:46 maxv Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: sys_module.c,v 1.15 2014/07/10 19:12:07 maxv Exp $); +__KERNEL_RCSID(0, $NetBSD: sys_module.c,v 1.16 2014/07/10 19:21:46 maxv Exp $); #include sys/param.h #include sys/systm.h @@ -62,36 +62,35 @@ handle_modctl_load(modctl_load_t *ml) if ((ml-ml_props != NULL ml-ml_propslen == 0) || (ml-ml_props == NULL ml-ml_propslen 0)) { - error = EINVAL; - goto out1; + return EINVAL; } path = PNBUF_GET(); error = copyinstr(ml-ml_filename, path, MAXPATHLEN, NULL); if (error != 0) - goto out2; + goto out1; if (ml-ml_props != NULL) { if (ml-ml_propslen MAXPROPSLEN) { error = ENOMEM; - goto out2; + goto out1; } propslen = ml-ml_propslen + 1; props = (char *)kmem_alloc(propslen, KM_SLEEP); if (props == NULL) { error = ENOMEM; - goto out2; + goto out1; } error = copyinstr(ml-ml_props, props, propslen, NULL); if (error != 0) - goto out3; + goto out2; dict = prop_dictionary_internalize(props); if (dict == NULL) { error = EINVAL; - goto out3; + goto out2; } } else { dict = NULL; @@ -104,14 +103,12 @@ handle_modctl_load(modctl_load_t *ml) prop_object_release(dict); } -out3: +out2: if (props != NULL) { kmem_free(props, propslen); } -out2: - PNBUF_PUT(path); out1: - + PNBUF_PUT(path); return error; }
CVS commit: src/sbin/fsck_msdos
Module Name:src Committed By: christos Date: Thu Jul 10 21:00:52 UTC 2014 Modified Files: src/sbin/fsck_msdos: fat.c Log Message: Bring in a regression for the previous fix from OpenBSD To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/sbin/fsck_msdos/fat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/fsck_msdos/fat.c diff -u src/sbin/fsck_msdos/fat.c:1.27 src/sbin/fsck_msdos/fat.c:1.28 --- src/sbin/fsck_msdos/fat.c:1.27 Mon Jul 7 14:46:45 2014 +++ src/sbin/fsck_msdos/fat.c Thu Jul 10 17:00:52 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: fat.c,v 1.27 2014/07/07 18:46:45 christos Exp $ */ +/* $NetBSD: fat.c,v 1.28 2014/07/10 21:00:52 christos Exp $ */ /* * Copyright (C) 1995, 1996, 1997 Wolfgang Solfrank @@ -28,7 +28,7 @@ #include sys/cdefs.h #ifndef lint -__RCSID($NetBSD: fat.c,v 1.27 2014/07/07 18:46:45 christos Exp $); +__RCSID($NetBSD: fat.c,v 1.28 2014/07/10 21:00:52 christos Exp $); #endif /* not lint */ #include stdlib.h @@ -555,13 +555,13 @@ writefat(int fs, struct bootblock *boot, if (fat[cl].next == CLUST_FREE) boot-NumFree++; *p++ = (u_char)fat[cl].next; - *p++ = (u_char)((fat[cl].next 8) 0xf); + *p = (u_char)((fat[cl].next 8) 0xf); cl++; if (cl = boot-NumClusters) break; if (fat[cl].next == CLUST_FREE) boot-NumFree++; - *p |= (u_char)(fat[cl + 1].next 4); + *p++ |= (u_char)(fat[cl + 1].next 4); *p++ = (u_char)(fat[cl + 1].next 4); break; }
CVS commit: src/sbin/fsck_msdos
Module Name:src Committed By: christos Date: Thu Jul 10 21:06:20 UTC 2014 Modified Files: src/sbin/fsck_msdos: check.c Log Message: Well, if you set FSFIXFAT, better do it... Try running fsck on: $ newfs_msdos -C 1M ./poc.fs $ dd if=/dev/zero of=poc.fs conv=notrunc bs=1 count=1 seek=512 multiple times and see that it does not get fixed. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sbin/fsck_msdos/check.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/fsck_msdos/check.c diff -u src/sbin/fsck_msdos/check.c:1.18 src/sbin/fsck_msdos/check.c:1.19 --- src/sbin/fsck_msdos/check.c:1.18 Sat Apr 11 03:14:50 2009 +++ src/sbin/fsck_msdos/check.c Thu Jul 10 17:06:20 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: check.c,v 1.18 2009/04/11 07:14:50 lukem Exp $ */ +/* $NetBSD: check.c,v 1.19 2014/07/10 21:06:20 christos Exp $ */ /* * Copyright (C) 1995, 1996, 1997 Wolfgang Solfrank @@ -28,7 +28,7 @@ #include sys/cdefs.h #ifndef lint -__RCSID($NetBSD: check.c,v 1.18 2009/04/11 07:14:50 lukem Exp $); +__RCSID($NetBSD: check.c,v 1.19 2014/07/10 21:06:20 christos Exp $); #endif /* not lint */ #include stdlib.h @@ -135,7 +135,7 @@ checkfilesys(const char *filename) goto out; /* now write the FATs */ - if (mod FSFATMOD) { + if (mod (FSFATMOD|FSFIXFAT)) { if (ask(1, Update FATs)) { mod |= writefat(dosfs, boot, fat, mod FSFIXFAT); if (mod FSFATAL)
CVS commit: src/sys/kern
Module Name:src Committed By: christos Date: Thu Jul 10 21:13:52 UTC 2014 Modified Files: src/sys/kern: subr_extent.c subr_prof.c sys_module.c Log Message: don't cast void * in c. To generate a diff of this commit: cvs rdiff -u -r1.75 -r1.76 src/sys/kern/subr_extent.c cvs rdiff -u -r1.46 -r1.47 src/sys/kern/subr_prof.c cvs rdiff -u -r1.16 -r1.17 src/sys/kern/sys_module.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_extent.c diff -u src/sys/kern/subr_extent.c:1.75 src/sys/kern/subr_extent.c:1.76 --- src/sys/kern/subr_extent.c:1.75 Sun Jan 29 06:14:49 2012 +++ src/sys/kern/subr_extent.c Thu Jul 10 17:13:52 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_extent.c,v 1.75 2012/01/29 11:14:49 para Exp $ */ +/* $NetBSD: subr_extent.c,v 1.76 2014/07/10 21:13:52 christos Exp $ */ /*- * Copyright (c) 1996, 1998, 2007 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: subr_extent.c,v 1.75 2012/01/29 11:14:49 para Exp $); +__KERNEL_RCSID(0, $NetBSD: subr_extent.c,v 1.76 2014/07/10 21:13:52 christos Exp $); #ifdef _KERNEL #include opt_lockdebug.h @@ -283,7 +283,7 @@ extent_create(const char *name, u_long s LIST_INSERT_HEAD(fex-fex_freelist, rp, er_link); } } else { - ex = (struct extent *)kmem_alloc(sizeof(struct extent), + ex = kmem_alloc(sizeof(*ex), (flags EX_WAITOK) ? KM_SLEEP : KM_NOSLEEP); if (ex == NULL) return (NULL); Index: src/sys/kern/subr_prof.c diff -u src/sys/kern/subr_prof.c:1.46 src/sys/kern/subr_prof.c:1.47 --- src/sys/kern/subr_prof.c:1.46 Tue Feb 25 13:30:11 2014 +++ src/sys/kern/subr_prof.c Thu Jul 10 17:13:52 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_prof.c,v 1.46 2014/02/25 18:30:11 pooka Exp $ */ +/* $NetBSD: subr_prof.c,v 1.47 2014/07/10 21:13:52 christos Exp $ */ /*- * Copyright (c) 1982, 1986, 1993 @@ -32,7 +32,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: subr_prof.c,v 1.46 2014/02/25 18:30:11 pooka Exp $); +__KERNEL_RCSID(0, $NetBSD: subr_prof.c,v 1.47 2014/07/10 21:13:52 christos Exp $); #include sys/param.h #include sys/systm.h @@ -86,7 +86,7 @@ kmstartup(void) else if (p-tolimit MAXARCS) p-tolimit = MAXARCS; p-tossize = p-tolimit * sizeof(struct tostruct); - cp = (char *)malloc(p-kcountsize + p-fromssize + p-tossize, + cp = malloc(p-kcountsize + p-fromssize + p-tossize, M_GPROF, M_NOWAIT | M_ZERO); if (cp == 0) { printf(No memory for profiling.\n); Index: src/sys/kern/sys_module.c diff -u src/sys/kern/sys_module.c:1.16 src/sys/kern/sys_module.c:1.17 --- src/sys/kern/sys_module.c:1.16 Thu Jul 10 15:21:46 2014 +++ src/sys/kern/sys_module.c Thu Jul 10 17:13:52 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: sys_module.c,v 1.16 2014/07/10 19:21:46 maxv Exp $ */ +/* $NetBSD: sys_module.c,v 1.17 2014/07/10 21:13:52 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: sys_module.c,v 1.16 2014/07/10 19:21:46 maxv Exp $); +__KERNEL_RCSID(0, $NetBSD: sys_module.c,v 1.17 2014/07/10 21:13:52 christos Exp $); #include sys/param.h #include sys/systm.h @@ -77,7 +77,7 @@ handle_modctl_load(modctl_load_t *ml) } propslen = ml-ml_propslen + 1; - props = (char *)kmem_alloc(propslen, KM_SLEEP); + props = kmem_alloc(propslen, KM_SLEEP); if (props == NULL) { error = ENOMEM; goto out1;
CVS commit: src/sys/dev/pci
Module Name:src Committed By: msaitoh Date: Fri Jul 11 02:23:44 UTC 2014 Modified Files: src/sys/dev/pci: if_wm.c if_wmreg.h Log Message: Fix some bugs realted to semaphore. This change fixes a problem which was exposed in if_wm.c rev. 1.271. Tested by riastradh@. - Clear the SMBI bit in SWSM register before accessing NVM and PHY in wm_attach(). Same as FreeBSD. - Fix a bug that 82573 doesn't put the hardware semaphore. Same as FreeBSD r256200. To generate a diff of this commit: cvs rdiff -u -r1.272 -r1.273 src/sys/dev/pci/if_wm.c cvs rdiff -u -r1.56 -r1.57 src/sys/dev/pci/if_wmreg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/if_wm.c diff -u src/sys/dev/pci/if_wm.c:1.272 src/sys/dev/pci/if_wm.c:1.273 --- src/sys/dev/pci/if_wm.c:1.272 Tue Jul 1 10:35:18 2014 +++ src/sys/dev/pci/if_wm.c Fri Jul 11 02:23:44 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wm.c,v 1.272 2014/07/01 10:35:18 ozaki-r Exp $ */ +/* $NetBSD: if_wm.c,v 1.273 2014/07/11 02:23:44 msaitoh Exp $ */ /* * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc. @@ -76,7 +76,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: if_wm.c,v 1.272 2014/07/01 10:35:18 ozaki-r Exp $); +__KERNEL_RCSID(0, $NetBSD: if_wm.c,v 1.273 2014/07/11 02:23:44 msaitoh Exp $); #include sys/param.h #include sys/systm.h @@ -1202,6 +1202,7 @@ wm_attach(device_t parent, device_t self uint16_t cfg1, cfg2, swdpin, io3; pcireg_t preg, memtype; uint16_t eeprom_data, apme_mask; + bool force_clear_smbi; uint32_t reg; char intrbuf[PCI_INTRSTR_LEN]; @@ -1393,7 +1394,6 @@ wm_attach(device_t parent, device_t self (sc-sc_type != WM_T_PCH) (sc-sc_type != WM_T_PCH2) (sc-sc_type != WM_T_PCH_LPT)) { - sc-sc_flags |= WM_F_EEPROM_SEMAPHORE; /* ICH* and PCH* have no PCIe capability registers */ if (pci_get_capability(pa-pa_pc, pa-pa_tag, PCI_CAP_PCIEXPRESS, sc-sc_pcixe_capoff, @@ -1611,9 +1611,12 @@ wm_attach(device_t parent, device_t self case WM_T_82572: /* SPI */ wm_set_spiaddrbits(sc); + sc-sc_flags |= WM_F_EEPROM_SEMAPHORE; sc-sc_flags |= WM_F_EEPROM_HANDSHAKE; break; case WM_T_82573: + sc-sc_flags |= WM_F_EEPROM_SEMAPHORE; + /* FALLTHROUGH */ case WM_T_82574: case WM_T_82583: if (wm_is_onboard_nvm_eeprom(sc) == 0) @@ -1669,6 +1672,29 @@ wm_attach(device_t parent, device_t self break; } + /* Ensure the SMBI bit is clear before first NVM or PHY access */ + switch (sc-sc_type) { + case WM_T_82571: + case WM_T_82572: + reg = CSR_READ(sc, WMREG_SWSM2); + if ((reg SWSM2_LOCK) != 0) { + CSR_WRITE(sc, WMREG_SWSM2, reg | SWSM2_LOCK); + force_clear_smbi = true; + } else + force_clear_smbi = false; + break; + default: + force_clear_smbi = true; + break; + } + if (force_clear_smbi) { + reg = CSR_READ(sc, WMREG_SWSM); + if ((reg ~SWSM_SMBI) != 0) + aprint_error_dev(sc-sc_dev, + Please update the Bootagent\n); + CSR_WRITE(sc, WMREG_SWSM, reg ~SWSM_SMBI); + } + /* * Defer printing the EEPROM type until after verifying the checksum * This allows the EEPROM type to be printed correctly in the case @@ -4196,6 +4222,7 @@ static void wm_reset(struct wm_softc *sc) { int phy_reset = 0; + int error = 0; uint32_t reg, mask; /* @@ -4298,7 +4325,7 @@ wm_reset(struct wm_softc *sc) case WM_T_82573: case WM_T_82574: case WM_T_82583: - wm_get_hw_semaphore_82573(sc); + error = wm_get_hw_semaphore_82573(sc); break; default: break; @@ -4404,9 +4431,11 @@ wm_reset(struct wm_softc *sc) /* Must release the MDIO ownership after MAC reset */ switch (sc-sc_type) { + case WM_T_82573: case WM_T_82574: case WM_T_82583: - wm_put_hw_semaphore_82573(sc); + if (error == 0) + wm_put_hw_semaphore_82573(sc); break; default: break; Index: src/sys/dev/pci/if_wmreg.h diff -u src/sys/dev/pci/if_wmreg.h:1.56 src/sys/dev/pci/if_wmreg.h:1.57 --- src/sys/dev/pci/if_wmreg.h:1.56 Fri Apr 11 04:42:34 2014 +++ src/sys/dev/pci/if_wmreg.h Fri Jul 11 02:23:44 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wmreg.h,v 1.56 2014/04/11 04:42:34 msaitoh Exp $ */ +/* $NetBSD: if_wmreg.h,v 1.57 2014/07/11 02:23:44 msaitoh Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. @@ -928,6 +928,9 @@ struct livengood_tcpip_ctxdesc { #define FWSM_RSPCIPHY 0x0040 /* Reset PHY on PCI reset */ #define FWSM_FW_VALID 0x8000 /* FW established a valid mode */ +#define WMREG_SWSM2 0x5b58 /* SW Semaphore 2 */ +#define SWSM2_LOCK 0x0002 /* Secondary driver semaphore bit */ + #define WMREG_SW_FW_SYNC 0x5b5c /* software-firmware semaphore */ #define SWFW_EEP_SM 0x0001 /* eeprom access */ #define SWFW_PHY0_SM 0x0002 /* first ctrl phy access */