kernel: Add a number of missing crit_exit, lwkt_reltoken, rel_mplock, etc.
authorSascha Wildner <saw@online.de>
Sun, 8 Jun 2014 09:32:23 +0000 (11:32 +0200)
committerSascha Wildner <saw@online.de>
Sun, 8 Jun 2014 09:32:23 +0000 (11:32 +0200)
sys/dev/misc/snp/snp.c
sys/dev/misc/sysvipc/sysvipc.c
sys/dev/raid/hpt27xx/osm_bsd.c
sys/dev/raid/mfi/mfi.c
sys/dev/serial/cy/cy.c
sys/dev/serial/si/si.c
sys/dev/serial/sio/sio.c
sys/net/sppp/if_spppsubr.c
sys/netproto/ipsec/key.c
sys/vfs/nfs/nfs_vnops.c

index 69fba20..1d83373 100644 (file)
@@ -718,8 +718,10 @@ snp_modevent(module_t mod, int type, void *data)
                }
                break;
        case MOD_UNLOAD:
-               if (!LIST_EMPTY(&snp_sclist))
+               if (!LIST_EMPTY(&snp_sclist)) {
+                       lwkt_reltoken(&tty_token);
                        return (EBUSY);
+               }
                ldisc_deregister(snooplinedisc);
                devfs_clone_handler_del("snp");
                dev_ops_remove_all(&snp_ops);
index e5498b3..01378da 100644 (file)
@@ -398,8 +398,10 @@ sysvipc_dev_ioctl(struct dev_ioctl_args *ap)
                 * list of consumed requests.
                 */
                req = TAILQ_LAST( &sysv->req_list, _req_list);
-               if(!req)
+               if(!req) {
+                       lockmgr(&sysv->req_mtx, LK_RELEASE);
                        return (EINVAL);
+               }
                TAILQ_REMOVE(&sysv->req_list, req, req_link);
                lockmgr(&sysv->req_mtx, LK_RELEASE);
 
index 0f0d75f..ce88981 100644 (file)
@@ -1340,10 +1340,11 @@ static int      hpt_rescan_bus(void)
 
        ldm_for_each_vbus(vbus, vbus_ext) {
                if (xpt_create_path(&path, xpt_periph, cam_sim_path(vbus_ext->sim),
-                       CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP)
+                       CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
+                       rel_mplock();
                        return(EIO);
-               if ((ccb = kmalloc(sizeof(union ccb), M_TEMP, M_WAITOK)) == NULL)
-                       return(ENOMEM);
+               }
+               ccb = kmalloc(sizeof(union ccb), M_TEMP, M_WAITOK);
                bzero(ccb, sizeof(union ccb));
                xpt_setup_ccb(&ccb->ccb_h, path, 5);
                ccb->ccb_h.func_code = XPT_SCAN_BUS;
index 18f5bf2..e906272 100644 (file)
@@ -905,8 +905,10 @@ mfi_comms_init(struct mfi_softc *sc)
        uint32_t context = 0;
 
        lockmgr(&sc->mfi_io_lock, LK_EXCLUSIVE);
-       if ((cm = mfi_dequeue_free(sc)) == NULL)
+       if ((cm = mfi_dequeue_free(sc)) == NULL) {
+               lockmgr(&sc->mfi_io_lock, LK_RELEASE);
                return (EBUSY);
+       }
 
        /* Zero out the MFI frame */
        context = cm->cm_frame->header.context;
index 574733d..95465fb 100644 (file)
@@ -896,6 +896,7 @@ siowrite(struct dev_write_args *ap)
        int             mynor;
        struct tty      *tp;
        int             unit;
+       int             ret;
 
        mynor = minor(dev);
        if (mynor & CONTROL_MASK)
@@ -917,10 +918,12 @@ siowrite(struct dev_write_args *ap)
         * CR & LF chars.  Hardly worth the effort, given that high-throughput
         * sessions are raw anyhow.
         */
+       ret = 0;
 #else
-       return ((*linesw[tp->t_line].l_write)(tp, uio, ap->a_ioflag));
+       ret = (*linesw[tp->t_line].l_write)(tp, uio, ap->a_ioflag);
 #endif
        lwkt_reltoken(&tty_token);
+       return(ret);
 }
 
 static void
index 48ed1ff..cc21700 100644 (file)
@@ -1001,8 +1001,10 @@ siioctl(struct dev_ioctl_args *ap)
                switch (cmd) {
                case TIOCSETA:
                        error = priv_check_cred(ap->a_cred, PRIV_ROOT, 0);
-                       if (error != 0)
+                       if (error != 0) {
+                               lwkt_reltoken(&tty_token);
                                return (error);
+                       }
                        *ct = *(struct termios *)data;
                        lwkt_reltoken(&tty_token);
                        return (0);
index 3782711..d61aa0a 100644 (file)
@@ -2040,8 +2040,10 @@ sioioctl(struct dev_ioctl_args *ap)
                switch (ap->a_cmd) {
                case TIOCSETA:
                        error = priv_check_cred(ap->a_cred, PRIV_ROOT, 0);
-                       if (error != 0)
+                       if (error != 0) {
+                               lwkt_reltoken(&tty_token);
                                return (error);
+                       }
                        *ct = *(struct termios *)data;
                        lwkt_reltoken(&tty_token);
                        return (0);
index 4d2693a..b412bc8 100644 (file)
@@ -1150,15 +1150,19 @@ sppp_ioctl(struct ifnet *ifp, IOCTL_CMD_T cmd, void *data)
 #define ifr_mtu ifr_metric
 #endif
        case SIOCSIFMTU:
-               if (ifr->ifr_mtu < 128 || ifr->ifr_mtu > sp->lcp.their_mru)
+               if (ifr->ifr_mtu < 128 || ifr->ifr_mtu > sp->lcp.their_mru) {
+                       crit_exit();
                        return (EINVAL);
+               }
                ifp->if_mtu = ifr->ifr_mtu;
                break;
 #endif
 #ifdef SLIOCSETMTU
        case SLIOCSETMTU:
-               if (*(short*)data < 128 || *(short*)data > sp->lcp.their_mru)
+               if (*(short*)data < 128 || *(short*)data > sp->lcp.their_mru) {
+                       crit_exit();
                        return (EINVAL);
+               }
                ifp->if_mtu = *(short*)data;
                break;
 #endif
index a6c9039..a7135ae 100644 (file)
@@ -2459,7 +2459,9 @@ key_spdexpire(struct secpolicy *sp)
        mtod(result, struct sadb_msg *)->sadb_msg_len =
            PFKEY_UNIT64(result->m_pkthdr.len);
 
-       return key_sendup_mbuf(NULL, result, KEY_SENDUP_REGISTERED);
+       error = key_sendup_mbuf(NULL, result, KEY_SENDUP_REGISTERED);
+       crit_exit();
+       return error;
 
  fail:
        if (result)
index 688d28e..64f891c 100644 (file)
@@ -541,8 +541,10 @@ nfs_open(struct vop_open_args *ap)
                np->n_attrstamp = 0;
                if (vp->v_type == VDIR) {
                        error = nfs_vinvalbuf(vp, V_SAVE, 1);
-                       if (error == EINTR)
+                       if (error == EINTR) {
+                               lwkt_reltoken(&nmp->nm_token);
                                return (error);
+                       }
                        nfs_invaldir(vp);
                }
        }
@@ -810,8 +812,10 @@ again:
                 */
                if (np->n_flag & NRMODIFIED)
                        error = nfs_vinvalbuf(vp, V_SAVE, 1);
-               if (error == EINTR)
+               if (error == EINTR) {
+                       lwkt_reltoken(&nmp->nm_token);
                        return (error);
+               }
                if (error == 0) {
                        if (vap->va_mtime.tv_sec != VNOVAL) {
                                np->n_mtime = vap->va_mtime.tv_sec;