FreeBSD Bugzilla – Attachment 236405 Details for
Bug 250309
devmatch: panic: general protection fault: sysctl_devices() -> sysctl_root_handler_locked() in hw.bus.devices sysctl handler when plugging in USB mouse
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
updated patch
patch2.diff (text/plain), 2.54 KB, created by
sigsys
on 2022-09-07 00:30:49 UTC
(
hide
)
Description:
updated patch
Filename:
MIME Type:
Creator:
sigsys
Created:
2022-09-07 00:30:49 UTC
Size:
2.54 KB
patch
obsolete
>diff --git c/sys/kern/subr_bus.c i/sys/kern/subr_bus.c >index 041e77259313..16acb9e2ee4e 100644 >--- c/sys/kern/subr_bus.c >+++ i/sys/kern/subr_bus.c >@@ -351,6 +351,7 @@ device_sysctl_fini(device_t dev) > } > > static struct device_list bus_data_devices; >+static struct sx bus_data_sx; > static int bus_data_generation = 1; > > static kobj_method_t null_methods[] = { >@@ -1351,7 +1352,9 @@ make_device(device_t parent, const char *name, int unit) > > dev->state = DS_NOTPRESENT; > >+ sx_xlock(&bus_data_sx); > TAILQ_INSERT_TAIL(&bus_data_devices, dev, devlink); >+ sx_xunlock(&bus_data_sx); > bus_data_generation_update(); > > return (dev); >@@ -1491,9 +1494,11 @@ device_delete_child(device_t dev, device_t child) > devclass_delete_device(child->devclass, child); > if (child->parent) > BUS_CHILD_DELETED(dev, child); >+ sx_xlock(&bus_data_sx); > TAILQ_REMOVE(&dev->children, child, link); > TAILQ_REMOVE(&bus_data_devices, child, devlink); > kobj_delete((kobj_t) child, M_BUS); >+ sx_xunlock(&bus_data_sx); > > bus_data_generation_update(); > return (0); >@@ -4790,6 +4795,7 @@ root_bus_module_handler(module_t mod, int what, void* arg) > switch (what) { > case MOD_LOAD: > TAILQ_INIT(&bus_data_devices); >+ sx_init(&bus_data_sx, "bus_data_sx"); > kobj_class_compile((kobj_class_t) &root_driver); > root_bus = make_device(NULL, "root", 0); > root_bus->desc = "System root bus"; >@@ -5131,19 +5137,24 @@ sysctl_devices(SYSCTL_HANDLER_ARGS) > /* > * Scan the list of devices, looking for the requested index. > */ >+ sx_slock(&bus_data_sx); > TAILQ_FOREACH(dev, &bus_data_devices, devlink) { > if (index-- == 0) > break; > } >- if (dev == NULL) >- return (ENOENT); >+ if (dev == NULL) { >+ error = ENOENT; >+ goto out; >+ } > > /* > * Populate the return item, careful not to overflow the buffer. > */ > udev = malloc(sizeof(*udev), M_BUS, M_WAITOK | M_ZERO); >- if (udev == NULL) >- return (ENOMEM); >+ if (udev == NULL) { >+ error = ENOMEM; >+ goto out; >+ } > udev->dv_handle = (uintptr_t)dev; > udev->dv_parent = (uintptr_t)dev->parent; > udev->dv_devflags = dev->devflags; >@@ -5168,6 +5179,7 @@ sysctl_devices(SYSCTL_HANDLER_ARGS) > error = SYSCTL_OUT(req, udev, sizeof(*udev)); > sbuf_delete(&sb); > free(udev, M_BUS); >+out: sx_sunlock(&bus_data_sx); > return (error); > } > >@@ -5204,11 +5216,13 @@ device_lookup_by_name(const char *name) > { > device_t dev; > >+ sx_slock(&bus_data_sx); > TAILQ_FOREACH(dev, &bus_data_devices, devlink) { > if (dev->nameunit != NULL && strcmp(dev->nameunit, name) == 0) >- return (dev); >+ break; > } >- return (NULL); >+ sx_sunlock(&bus_data_sx); >+ return (dev); > } > > /*
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 250309
: 236405