From b62c0a81712646214cb1bea98649e76f39ead2d0 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Fri, 5 Jul 2019 16:47:39 +0200 Subject: [PATCH] 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 --- tests/mockup/gpio-mockup.c | 6 ------ 1 file changed, 6 deletions(-) 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; -- 2.30.2