From: Bartosz Golaszewski Date: Mon, 23 Oct 2017 21:29:16 +0000 (+0200) Subject: core: fix an error path in line event requests X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=902113297be8b6a6dcf910e9a833bd4a529f8fc5;p=qemu-gpiodev%2Flibgpiod.git core: fix an error path in line event requests Correctly release already requested lines in case of an error in line_request_event_single(). Signed-off-by: Bartosz Golaszewski --- diff --git a/src/lib/core.c b/src/lib/core.c index 4cac1e4..9410601 100644 --- a/src/lib/core.c +++ b/src/lib/core.c @@ -417,14 +417,14 @@ static int line_request_events(struct gpiod_line_bulk *bulk, const struct gpiod_line_request_config *config) { struct gpiod_line *line; - unsigned int off, i; - int rv; + unsigned int off; + int rv, rev; gpiod_line_bulk_foreach_line_off(bulk, line, off) { rv = line_request_event_single(line, config); if (rv) { - for (i = off - 1; off > 0; off--) { - line = gpiod_line_bulk_get_line(bulk, i); + for (rev = off - 1; rev >= 0; rev--) { + line = gpiod_line_bulk_get_line(bulk, rev); gpiod_line_release(line); }