diff options
| author | Jerry Gilliam <Jerry.Gilliam@Sun.COM> | 2010-06-08 13:46:34 -0700 |
|---|---|---|
| committer | Jerry Gilliam <Jerry.Gilliam@Sun.COM> | 2010-06-08 13:46:34 -0700 |
| commit | c8742f6496e41bcf40b54b09b48835c42f91e574 (patch) | |
| tree | 30c6569140979ed1e980ac6c804767152de20246 /usr/src/uts/common/os/modsubr.c | |
| parent | 837b568b3a2559f8c9b9403f95104271a85d129e (diff) | |
| download | illumos-joyent-c8742f6496e41bcf40b54b09b48835c42f91e574.tar.gz | |
6955559 ddi_driver_name() returns NULL to e_ddi_free_instance(), leading to a bad trap panic in in_drvwalk()
Diffstat (limited to 'usr/src/uts/common/os/modsubr.c')
| -rw-r--r-- | usr/src/uts/common/os/modsubr.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/usr/src/uts/common/os/modsubr.c b/usr/src/uts/common/os/modsubr.c index b75c772d14..cccffffaba 100644 --- a/usr/src/uts/common/os/modsubr.c +++ b/usr/src/uts/common/os/modsubr.c @@ -19,8 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ #include <sys/param.h> @@ -73,10 +72,22 @@ static void hwc_hash(struct hwc_spec *, major_t); static void hwc_unhash(struct hwc_spec *); int +major_valid(major_t major) +{ + return (major != DDI_MAJOR_T_NONE && + (major >= 0 && major < devcnt)); +} + +int driver_installed(major_t major) { - return ((major < devcnt) && (major != DDI_MAJOR_T_NONE) && - !(devnamesp[major].dn_flags & + return (major_valid(major) && devnamesp[major].dn_name != NULL); +} + +int +driver_active(major_t major) +{ + return (driver_installed(major) && !(devnamesp[major].dn_flags & (DN_DRIVER_REMOVED|DN_DRIVER_INACTIVE))); } @@ -87,7 +98,7 @@ mod_hold_dev_by_major(major_t major) int loaded; char *drvname; - if (!driver_installed(major)) + if (!driver_active(major)) return (NULL); LOCK_DEV_OPS(&(devnamesp[major].dn_lock)); @@ -121,7 +132,7 @@ mod_rele_dev_by_major(major_t major) struct dev_ops *ops; struct devnames *dnp; - if (!driver_installed(major)) + if (!driver_active(major)) return; dnp = &devnamesp[major]; |
