From: Bartosz Golaszewski Date: Fri, 5 Jul 2019 14:47:39 +0000 (+0200) Subject: tests: gpio-mockup: don't allocate the chip structure twice X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=b62c0a81712646214cb1bea98649e76f39ead2d0;p=qemu-gpiodev%2Flibgpiod.git tests: gpio-mockup: don't allocate the chip structure twice We incorrectly allocate the chip structure twice: once in gpio_mockup_probe() and then again in make_chip() which leads to a memory leak. Remove the first instance as it's the one that's unnecessary. 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 2af3c31..358fec6 100644 --- a/tests/mockup/gpio-mockup.c +++ b/tests/mockup/gpio-mockup.c @@ -304,12 +304,6 @@ EXPORT int gpio_mockup_probe(struct gpio_mockup *ctx, unsigned int num_chips, if (!ctx->chips) goto err_remove_module; - for (i = 0; i < num_chips; i++) { - ctx->chips[i] = malloc(sizeof(struct gpio_mockup_chip)); - if (!ctx->chips[i]) - goto err_free_chips; - } - pfd.fd = udev_monitor_get_fd(monitor); pfd.events = POLLIN | POLLPRI;