Closed tyreld closed 2 years ago
get_drc_info(const char *of_path)
{
struct stat sbuf;
char fname[DR_PATH_MAX];
char ofdt_path[DR_PATH_MAX];
char *full_path = NULL;
struct dr_connector *list = NULL;
int rc;
for (list = all_drc_lists; list; list = list->all_next) {
if (! strcmp(list->ofdt_path, of_path))
return list;
}
full_path = of_to_full_path(of_path);
if (full_path == NULL)
return NULL;
/* ibm,drc-info vs the old implementation */
sprintf(fname, "%s/%s", full_path, "ibm,drc-info");
snprintf(ofdt_path, DR_PATH_MAX, "%s", of_path);
rc = stat(fname, &sbuf);
if (rc)
rc = drc_info_connectors_v1(full_path, ofdt_path, &list);
else
rc = drc_info_connectors_v2(full_path, ofdt_path, &list);
if (rc == 0) {
list->all_next = all_drc_lists;
all_drc_lists = list;
} else {
if (full_path)
free(full_path);
list = NULL;
}
return list;
}
full_path
is only freed if drc_info_connectors_vX()
fails. It should be freed regardless. Further, the if (full_path)
check is unnecessary as we return immediately if full_path
is NULL following of_to_full_path()
call.
This is in src/drmgr common code so I can only assume the same leaks are observed running drmgr.
Fixed by following commit:
313bb6fdc145 lsslot: fix memory leak when listing IO slots