drivers: serial: esp32_usb: fix interrupt-enable race condition
After enabling interrupts, serial_esp32_usb_irq_tx_enable() calls the interrupt handler to handle any old events that occurred while interrupts were disabled. However, this happens in the callers context, so if an interrupt arrives during the call, it will call the interrupt handler again resulting in corruption if the interrupt handler is not reentrant. Fixes #74569 Signed-off-by: Eric Holmberg <eric.holmberg@northriversystems.co.nz>
This commit is contained in:
parent
41c9ec3e42
commit
18ebfe59d0
1 changed files with 3 additions and 1 deletions
|
@ -142,7 +142,9 @@ static void serial_esp32_usb_irq_tx_enable(const struct device *dev)
|
|||
usb_serial_jtag_ll_ena_intr_mask(USB_SERIAL_JTAG_INTR_SERIAL_IN_EMPTY);
|
||||
|
||||
if (data->irq_cb != NULL) {
|
||||
unsigned int key = irq_lock();
|
||||
data->irq_cb(dev, data->irq_cb_data);
|
||||
arch_irq_unlock(key);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -220,8 +222,8 @@ static void serial_esp32_usb_irq_callback_set(const struct device *dev,
|
|||
{
|
||||
struct serial_esp32_usb_data *data = dev->data;
|
||||
|
||||
data->irq_cb = cb;
|
||||
data->irq_cb_data = cb_data;
|
||||
data->irq_cb = cb;
|
||||
}
|
||||
|
||||
static void serial_esp32_usb_isr(void *arg)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue