Source-Changes-HG archive

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

[src/prg-localcount2]: src/sys/dev Fix checking of failure-to-spawn a unit (c...



details:   https://anonhg.NetBSD.org/src/rev/4874d2ef8f7b
branches:  prg-localcount2
changeset: 823511:4874d2ef8f7b
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Thu Apr 27 11:58:58 2017 +0000

description:
Fix checking of failure-to-spawn a unit (check the returned address for
NULL, vs the pointer to that address).

Ensure that that device_release() is called in all exit paths from cgd_close().

Update handling of CGDIOCCLR ioctl the same as CGDIOCSET.  In particular,
don't return without calling device_release(), as any subsequent attempt to
detach the device will hang forever waiting for its localcount to drain.

diffstat:

 sys/dev/cgd.c |  17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)

diffs (52 lines):

diff -r a80b91845e6f -r 4874d2ef8f7b sys/dev/cgd.c
--- a/sys/dev/cgd.c     Thu Apr 27 05:36:30 2017 +0000
+++ b/sys/dev/cgd.c     Thu Apr 27 11:58:58 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cgd.c,v 1.114.4.1 2017/04/27 05:36:35 pgoyette Exp $ */
+/* $NetBSD: cgd.c,v 1.114.4.2 2017/04/27 11:58:58 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.114.4.1 2017/04/27 05:36:35 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.114.4.2 2017/04/27 11:58:58 pgoyette Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -388,8 +388,7 @@
        if (config_attach_pseudo(cf) == NULL)
                return NULL;
 
-       *self = device_lookup_acquire(&cgd_cd, unit);
-       if (self == NULL)
+       if ((*self = device_lookup_acquire(&cgd_cd, unit)) == NULL)
                return NULL;
        else {
                /*
@@ -451,8 +450,8 @@
                            "unable to detach instance\n");
                        return error;
                }
-       } else
-               device_release(self);
+       }
+       device_release(self);
        return 0;
 }
 
@@ -788,8 +787,10 @@
                break;
        case CGDIOCCLR:
                if (DK_BUSY(&cs->sc_dksc, pmask))
-                       return EBUSY;
-               return cgd_ioctl_clr(cs, l);
+                       error = EBUSY;
+               else
+                       error = cgd_ioctl_clr(cs, l);
+               break;
        case DIOCGCACHE:
        case DIOCCACHESYNC:
                if (!DK_ATTACHED(dksc))



Home | Main Index | Thread Index | Old Index