This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 3c7c88389a686e5803defbb3da768732dbf916cc Author: Marco Casaroli <[email protected]> AuthorDate: Mon Nov 2 10:49:44 2026 +0100 arch/avr/src/avrdx: Fix the error path of avrdx_ws2812_register(). When avrdx_swint_allocate() found no free software interrupt vector, avrdx_ws2812_register() went to errout with ret still OK. It freed the lane and returned OK, so the board code took the lane as registered. Return -ENOMEM in this case. The errout path also freed the per-lane transmit buffer, timestamp and 9th bit array, but left the global pointers to them set. Set them to NULL after the free. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]> --- arch/avr/src/avrdx/avrdx_ws2812.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/avr/src/avrdx/avrdx_ws2812.c b/arch/avr/src/avrdx/avrdx_ws2812.c index 657b93e38ae..e9f6766b455 100644 --- a/arch/avr/src/avrdx/avrdx_ws2812.c +++ b/arch/avr/src/avrdx/avrdx_ws2812.c @@ -924,7 +924,7 @@ static ssize_t avrdx_ws2812_read(struct file *filep, * Returned Value: * OK or negated errno. * ENOMEM - if the LED count exceeds limit (in addition to memory - * allocation failure.) + * allocation failure and no free software interrupt vector.) * ENOTSUP - if support for white LED is requested and not disabled * (see #warning at the beginning of the file or description * of AVR_AVRDX_WS2812_NO_WHITE_LED configuration option) @@ -1259,7 +1259,8 @@ int avrdx_ws2812_register(const char *path, uint8_t count, avrdx_swint_allocate(transmission_completed, (void *)lane); if (g_avrdx_ws2812_swint_vector[lane] == 0) { - goto errout; /* No vector available */ + ret = -ENOMEM; /* No vector available */ + goto errout; } /* xmit_bytes are initialized to zero but we can't just put zero bytes @@ -1325,17 +1326,20 @@ errout: if (g_avrdx_ws2812_uart9_bytes[lane]) { kmm_free(g_avrdx_ws2812_uart9_bytes[lane]); + g_avrdx_ws2812_uart9_bytes[lane] = NULL; } #endif if (g_avrdx_ws2812_xmit_ts[lane]) { kmm_free(g_avrdx_ws2812_xmit_ts[lane]); + g_avrdx_ws2812_xmit_ts[lane] = NULL; } if (g_avrdx_ws2812_xmit_bytes[lane]) { kmm_free(g_avrdx_ws2812_xmit_bytes[lane]); + g_avrdx_ws2812_xmit_bytes[lane] = NULL; } return ret;
