Skip to content

Commit 59e74fd

Browse files
committed
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 <[email protected]> Approved by: imp (mentor, implicit) Differential Revision: https://reviews.freebsd.org/D51998
1 parent 39bdc7d commit 59e74fd

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

sys/dev/gpio/gpioc.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,11 @@ gpioc_allocate_pin_intr(struct gpioc_pin_intr *intr_conf, uint32_t flags)
208208
err = bus_setup_intr(intr_conf->pin->dev, intr_conf->intr_res,
209209
INTR_TYPE_MISC | INTR_MPSAFE, NULL, gpioc_interrupt_handler,
210210
intr_conf, &intr_conf->intr_cookie);
211-
if (err != 0)
211+
if (err != 0) {
212+
bus_release_resource(sc->sc_dev, intr_conf->intr_res);
213+
intr_conf->intr_res = NULL;
212214
goto error_exit;
215+
}
213216

214217
intr_conf->pin->flags = flags;
215218

0 commit comments

Comments
 (0)