Fix a couple of NULL dereferences in error paths.
authorSascha Wildner <saw@online.de>
Thu, 18 Apr 2019 14:53:24 +0000 (16:53 +0200)
committerSascha Wildner <saw@online.de>
Thu, 18 Apr 2019 14:53:24 +0000 (16:53 +0200)
sys/dev/disk/xdisk/xdisk.c
sys/dev/misc/snp/snp.c
sys/dev/raid/mrsas/mrsas.c
usr.bin/chpass/chpass.c

index 4684924..4da3ca0 100644 (file)
@@ -766,10 +766,8 @@ xa_close(struct dev_close_args *ap)
 
        lockmgr(&xdisk_lk, LK_EXCLUSIVE);
        sc = dev->si_drv1;
-       if (sc == NULL) {
-               lockmgr(&sc->lk, LK_RELEASE);
+       if (sc == NULL)
                return ENXIO;   /* raced destruction */
-       }
        if (sc->terminating) {
                lockmgr(&sc->lk, LK_RELEASE);
                return ENXIO;   /* raced destruction */
index 5685644..38415e0 100644 (file)
@@ -213,11 +213,9 @@ snpwrite(struct dev_write_args *ap)
 
        snp = dev->si_drv1;
        tp = snp->snp_tty;
-       lwkt_gettoken(&tp->t_token);
-       if (tp == NULL) {
-               lwkt_reltoken(&tp->t_token);
+       if (tp == NULL)
                return (EIO);
-       }
+       lwkt_gettoken(&tp->t_token);
        if ((tp->t_sc == snp) && (tp->t_state & TS_SNOOP) &&
            tp->t_line == snooplinedisc)
                goto tty_input;
index 44ac371..3bd4dac 100644 (file)
@@ -3562,7 +3562,7 @@ void mrsas_aen_handler(struct mrsas_softc *sc)
        int error;
 
        if (!sc) {
-               device_printf(sc->mrsas_dev, "invalid instance!\n");
+               kprintf("invalid instance!\n");
                return;
        }
 
index 2bf39b6..6db11c3 100644 (file)
@@ -36,7 +36,6 @@
  * @(#) Copyright (c) 1988, 1993, 1994 The Regents of the University of California.  All rights reserved.
  * @(#)chpass.c        8.4 (Berkeley) 4/2/94
  * $FreeBSD: src/usr.bin/chpass/chpass.c,v 1.28 2006/09/25 15:06:24 marck Exp $
- * $DragonFly: src/usr.bin/chpass/chpass.c,v 1.4 2003/11/03 19:31:28 eirikn Exp $
  */
 
 #include <sys/param.h>
@@ -229,8 +228,11 @@ main(int argc, char **argv)
 #ifdef YP
        case _PWF_NIS:
                ypclnt = ypclnt_new(yp_domain, "passwd.byname", yp_host);
-               if (ypclnt == NULL ||
-                   ypclnt_connect(ypclnt) == -1 ||
+               if (ypclnt == NULL) {
+                       warnx("ypclnt_new failed");
+                       exit(1);
+               }
+               if (ypclnt_connect(ypclnt) == -1 ||
                    ypclnt_passwd(ypclnt, pw, password) == -1) {
                        warnx("%s", ypclnt->error);
                        ypclnt_free(ypclnt);