Page MenuHomeFreeBSD

D52783.diff
No OneTemporary

D52783.diff

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
@@ -793,6 +793,7 @@
struct gpio_access_32 *a32;
struct gpio_config_32 *c32;
struct gpio_event_config *evcfg;
+ struct gpioc_pin_event *tmp;
uint32_t caps, intrflags;
switch (cmd) {
@@ -908,27 +909,35 @@
res = devfs_get_cdevpriv((void **)&priv);
if (res != 0)
break;
- /* If any pins have been configured, changes aren't allowed. */
- if (!SLIST_EMPTY(&priv->pins)) {
- res = EINVAL;
- break;
- }
if (evcfg->gp_report_type != GPIO_EVENT_REPORT_DETAIL &&
evcfg->gp_report_type != GPIO_EVENT_REPORT_SUMMARY) {
res = EINVAL;
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 &&
+ tmp = NULL;
+ 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 *
+ tmp = malloc(priv->numevents *
sizeof(struct gpioc_pin_event), M_GPIOC,
M_WAITOK | M_ZERO);
+ }
+ mtx_lock(&priv->mtx);
+ /* If any pins have been configured, changes aren't allowed. */
+ if (!SLIST_EMPTY(&priv->pins)) {
+ mtx_unlock(&priv->mtx);
+ free(tmp, M_GPIOC);
+ res = EINVAL;
+ break;
+ }
+ if (tmp != NULL) {
+ free(priv->events, M_GPIOC);
+ 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

Mime Type
text/plain
Expires
Sun, Dec 21, 12:24 PM (5 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
23173148
Default Alt Text
D52783.diff (1 KB)

Event Timeline