1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

device_id: fix memleak and free idname

Remove extra code path used only for 'free()'
and free(idname) on all paths that do not add it to list
and avoid memleak in few cases.
This commit is contained in:
Zdenek Kabelac 2021-04-23 00:25:14 +02:00
parent 65c4f81dc2
commit 80ef913872

View File

@ -1008,21 +1008,24 @@ id_done:
break;
}
}
if (found_id && !strcmp(id->idname, idname)) {
free((char *)idname);
} else if (found_id && strcmp(id->idname, idname)) {
if (found_id && idname && strcmp(id->idname, idname)) {
dm_list_del(&id->list);
free_did(id);
found_id = 0;
}
if (!found_id) {
if (!(id = zalloc(sizeof(struct dev_id))))
if (!(id = zalloc(sizeof(struct dev_id)))) {
free((char *)idname);
return_0;
}
id->idtype = idtype;
id->idname = (char *)idname;
id->dev = dev;
dm_list_add(&dev->ids, &id->list);
}
} else
free((char*)idname);
dev->id = id;
dev->flags |= DEV_MATCHED_USE_ID;