The branch main has been updated by vexeduxr:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=59e74fdfafcff3310c316dcec3bccfd04f8722b4

commit 59e74fdfafcff3310c316dcec3bccfd04f8722b4
Author:     Ahmad Khalifa <vexed...@freebsd.org>
AuthorDate: 2025-08-27 21:25:10 +0000
Commit:     Ahmad Khalifa <vexed...@freebsd.org>
CommitDate: 2025-08-27 21:38:32 +0000

    gpioc: cleanup if pin allocation fails
    
    gpioc normally depends on gpioc_cdevpriv_dtor to call
    gpioc_release_pin_intr when it's done with a pin. However, if
    gpioc_allocate_pin_intr fails, the pin is never added to the linked list
    which the destructor loops over to free the pins. Make it so
    gpioc_allocate_pin_intr cleans up after itself if it fails.
    
    Reported by:    Evgenii Ivanov <deviva...@proton.me>
    Approved by:    imp (mentor, implicit)
    Differential Revision:  https://reviews.freebsd.org/D51998
---
 sys/dev/gpio/gpioc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sys/dev/gpio/gpioc.c b/sys/dev/gpio/gpioc.c
index 87fed38ebe3e..77aaf2cb5447 100644
--- a/sys/dev/gpio/gpioc.c
+++ b/sys/dev/gpio/gpioc.c
@@ -208,8 +208,11 @@ gpioc_allocate_pin_intr(struct gpioc_pin_intr *intr_conf, 
uint32_t flags)
        err = bus_setup_intr(intr_conf->pin->dev, intr_conf->intr_res,
            INTR_TYPE_MISC | INTR_MPSAFE, NULL, gpioc_interrupt_handler,
            intr_conf, &intr_conf->intr_cookie);
-       if (err != 0)
+       if (err != 0) {
+               bus_release_resource(sc->sc_dev, intr_conf->intr_res);
+               intr_conf->intr_res = NULL;
                goto error_exit;
+       }
 
        intr_conf->pin->flags = flags;
 

Reply via email to