gpio:c fix for gpio_group memory leak
Signed-off-by: Cosmin Popescu <gabrielcosmin.popescu@gmail.com> Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
committed by
Mihai Tudor Panu
parent
18b4ac5663
commit
d60bab2082
@@ -270,6 +270,8 @@ mraa_gpio_chardev_init(int pins[], int num_pins)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dev->gpio_group = gpio_group;
|
||||||
|
|
||||||
for (int i = 0; i < dev->num_chips; ++i) {
|
for (int i = 0; i < dev->num_chips; ++i) {
|
||||||
gpio_group[i].gpio_chip = i;
|
gpio_group[i].gpio_chip = i;
|
||||||
/* Just to be sure realloc has the desired behaviour. */
|
/* Just to be sure realloc has the desired behaviour. */
|
||||||
@@ -381,8 +383,6 @@ mraa_gpio_chardev_init(int pins[], int num_pins)
|
|||||||
}
|
}
|
||||||
free(counters);
|
free(counters);
|
||||||
|
|
||||||
dev->gpio_group = gpio_group;
|
|
||||||
|
|
||||||
/* Save the provided array from the user to our internal structure. */
|
/* Save the provided array from the user to our internal structure. */
|
||||||
dev->provided_pins = malloc(dev->num_pins * sizeof(int));
|
dev->provided_pins = malloc(dev->num_pins * sizeof(int));
|
||||||
if (dev->provided_pins == NULL) {
|
if (dev->provided_pins == NULL) {
|
||||||
|
|||||||
Reference in New Issue
Block a user