1
0
mirror of https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git synced 2026-10-24 00:48:53 +03:00

tools: gpionotify: don't leak info returned by gpiod_chip_watch_line_info()

gpiod_chip_watch_line_info() returns a gpiod_line_info object that must
be freed by the caller. Add the missing call to gpiod_line_info_free().

Fixes: 5f194b001a ("tools: add gpionotify")
Tested-by: Vincent Fazio <vfazio@xes-inc.com>
Reviewed-by: Vincent Fazio <vfazio@xes-inc.com>
Link: https://patch.msgid.link/20260407-treewide-fixes-v1-12-66c9744a56a3@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
This commit is contained in:
Bartosz Golaszewski
2026-04-07 14:50:03 +02:00
parent da68c01be0
commit 0de77e2abf

View File

@@ -374,6 +374,7 @@ int main(int argc, char **argv)
int i, j, ret, events_done = 0, evtype;
struct line_resolver *resolver;
struct gpiod_info_event *event;
struct gpiod_line_info *info;
struct timespec idle_timeout;
struct gpiod_chip **chips;
struct gpiod_chip *chip;
@@ -405,13 +406,16 @@ int main(int argc, char **argv)
die_perror("unable to open chip '%s'",
resolver->chips[i].path);
for (j = 0; j < resolver->num_lines; j++)
if ((resolver->lines[j].chip_num == i) &&
!gpiod_chip_watch_line_info(
chip, resolver->lines[j].offset))
for (j = 0; j < resolver->num_lines; j++) {
info = gpiod_chip_watch_line_info(chip,
resolver->lines[j].offset);
if ((resolver->lines[j].chip_num == i) && !info)
die_perror("unable to watch line on chip '%s'",
resolver->chips[i].path);
gpiod_line_info_free(info);
}
chips[i] = chip;
pollfds[i].fd = gpiod_chip_get_fd(chip);
pollfds[i].events = POLLIN;