Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177867940
D52783.1795469623.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
D52783.1795469623.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);
+ void *tmp;
+
+ tmp = realloc(priv->events, evcfg->gp_fifo_size *
+ sizeof(struct gpioc_pin_event), M_GPIOC,
+ M_NOWAIT | M_ZERO);
+ if (tmp == NULL) {
+ res = ENOMEM;
+ mtx_unlock(&priv->mtx);
+ break;
+ }
+ priv->events = tmp;
priv->numevents = evcfg->gp_fifo_size;
- priv->events = malloc(priv->numevents *
- sizeof(struct gpioc_pint_event), M_GPIOC,
- M_WAITOK | M_ZERO);
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
Mon, Nov 23, 9:33 PM (13 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41940543
Default Alt Text
D52783.1795469623.diff (1 KB)
Attached To
Mode
D52783: gpioc: fix race in ioctl(GPIOCONFIGEVENTS)
Attached
Detach File
Event Timeline