Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F142720690
D52783.id163023.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D52783.id163023.diff
View Options
diff --git a/sys/dev/gpio/gpioc.c b/sys/dev/gpio/gpioc.c
--- a/sys/dev/gpio/gpioc.c
+++ b/sys/dev/gpio/gpioc.c
@@ -908,27 +908,38 @@
res = devfs_get_cdevpriv((void **)&priv);
if (res != 0)
break;
+ mtx_lock(&priv->mtx);
/* If any pins have been configured, changes aren't allowed. */
if (!SLIST_EMPTY(&priv->pins)) {
res = EINVAL;
+ mtx_unlock(&priv->mtx);
break;
}
if (evcfg->gp_report_type != GPIO_EVENT_REPORT_DETAIL &&
evcfg->gp_report_type != GPIO_EVENT_REPORT_SUMMARY) {
res = EINVAL;
+ mtx_unlock(&priv->mtx);
break;
}
- priv->report_option = evcfg->gp_report_type;
/* Reallocate the events buffer if the user wants it bigger. */
- if (priv->report_option == GPIO_EVENT_REPORT_DETAIL &&
+ if (evcfg->gp_report_type == GPIO_EVENT_REPORT_DETAIL &&
priv->numevents < evcfg->gp_fifo_size) {
- free(priv->events, M_GPIOC);
- priv->numevents = evcfg->gp_fifo_size;
- priv->events = malloc(priv->numevents *
+ void *tmp;
+
+ tmp = realloc(priv->events, evcfg->gp_fifo_size *
sizeof(struct gpio_event_detail), M_GPIOC,
- M_WAITOK | M_ZERO);
+ M_NOWAIT | M_ZERO);
+ if (tmp == NULL) {
+ res = ENOMEM;
+ mtx_unlock(&priv->mtx);
+ break;
+ }
+ priv->events = tmp;
+ priv->numevents = evcfg->gp_fifo_size;
priv->evidx_head = priv->evidx_tail = 0;
}
+ priv->report_option = evcfg->gp_report_type;
+ mtx_unlock(&priv->mtx);
break;
case FIONBIO:
/*
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 23, 4:14 PM (1 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27887436
Default Alt Text
D52783.id163023.diff (1 KB)
Attached To
Mode
D52783: gpioc: fix race in ioctl(GPIOCONFIGEVENTS)
Attached
Detach File
Event Timeline
Log In to Comment