mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
lscss: Fix memory leak
When the subchannel type read from sysfs does not match the requested type, the allocated path is not freed before continuing to the next loop iteration. This causes a memory leak as reported by valgrind. Free the path before continuing. Signed-off-by: Volkan Unal <vunal@linux.ibm.com> Reviewed-by: Vineeth Vijayan <vneethv@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
@@ -701,8 +701,10 @@ static void print_subchannels_of_type(enum sch_type type_requested,
|
||||
sch_dir = de_vec[i]->d_name;
|
||||
path = util_path_sysfs("bus/css/devices/%s", sch_dir);
|
||||
if (util_file_read_ul(&type_ul, 10, "%s/type", path) == 0) {
|
||||
if (type_ul != type_requested)
|
||||
if (type_ul != type_requested) {
|
||||
free(path);
|
||||
continue;
|
||||
}
|
||||
if (type_ul == SUBCHANNEL_TYPE_IO)
|
||||
print_sch_io(rec, path, sch_dir);
|
||||
else if (type_ul == SUBCHANNEL_TYPE_CHSC)
|
||||
|
||||
Reference in New Issue
Block a user