In build_channel_array(), count needs to be decreased in more places since
current->name and current->generic_name would be freed on the error path,
although they have not been allocated, yet.
This also requires to free current->name, when it is allocated, but
current->generic_name is not yet allocated.
Signed-off-by: Hartmut Knaack <knaack.h@gmx.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
if (sysfsfp == NULL) {
free(filename);
ret = -errno;
+ count--;
goto error_cleanup_array;
}
fscanf(sysfsfp, "%i", ¤t_enabled);
if (current->name == NULL) {
free(filename);
ret = -ENOMEM;
+ count--;
goto error_cleanup_array;
}
/* Get the generic and specific name elements */
¤t->generic_name);
if (ret) {
free(filename);
+ free(current->name);
+ count--;
goto error_cleanup_array;
}
ret = asprintf(&filename,