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:
Volkan Unal
2026-02-04 12:48:14 +00:00
committed by Jan Höppner
parent 11f2ccb957
commit 47cac92ca2

View File

@@ -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)