From: Bartosz Golaszewski Date: Fri, 5 Jul 2019 14:57:40 +0000 (+0200) Subject: tests: gpio-mockup: store the number of chips in gpio_mockup_probe() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=647cc34a1f1ac115e6278bceb95e18a75cc85def;p=qemu-gpiodev%2Flibgpiod.git tests: gpio-mockup: store the number of chips in gpio_mockup_probe() We're currently not storing the number of chips in the gpio-mockup context structure after probing the module. The value is left initialized to 0. This leads to both a memory leak and to chip ordering errors when running the tests at high CPU loads. This patch fixes both issues. Fixes: e43e46d4f79c ("tests: mockup: add a library for controlling the gpio-mockup module") Signed-off-by: Bartosz Golaszewski --- diff --git a/tests/mockup/gpio-mockup.c b/tests/mockup/gpio-mockup.c index 358fec6..5a2b64c 100644 --- a/tests/mockup/gpio-mockup.c +++ b/tests/mockup/gpio-mockup.c @@ -304,6 +304,8 @@ EXPORT int gpio_mockup_probe(struct gpio_mockup *ctx, unsigned int num_chips, if (!ctx->chips) goto err_remove_module; + ctx->num_chips = num_chips; + pfd.fd = udev_monitor_get_fd(monitor); pfd.events = POLLIN | POLLPRI;