mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
device_id: _get_devs_with_serial_numbers add missing free
on malloc failure path
This commit is contained in:
parent
7552ed9010
commit
e71b434663
@ -2124,11 +2124,11 @@ static void _get_devs_with_serial_numbers(struct cmd_context *cmd, struct dm_lis
|
|||||||
if (id->idtype == DEV_ID_TYPE_SYS_SERIAL) {
|
if (id->idtype == DEV_ID_TYPE_SYS_SERIAL) {
|
||||||
if (str_list_match_item(serial_str_list, id->idname)) {
|
if (str_list_match_item(serial_str_list, id->idname)) {
|
||||||
if (!(devl = dm_pool_zalloc(cmd->mem, sizeof(*devl))))
|
if (!(devl = dm_pool_zalloc(cmd->mem, sizeof(*devl))))
|
||||||
goto next_dev;
|
goto next_continue;
|
||||||
devl->dev = dev;
|
devl->dev = dev;
|
||||||
dm_list_add(devs, &devl->list);
|
dm_list_add(devs, &devl->list);
|
||||||
}
|
}
|
||||||
goto next_dev;
|
goto next_continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2145,20 +2145,22 @@ static void _get_devs_with_serial_numbers(struct cmd_context *cmd, struct dm_lis
|
|||||||
if ((idname = device_id_system_read(cmd, dev, DEV_ID_TYPE_SYS_SERIAL))) {
|
if ((idname = device_id_system_read(cmd, dev, DEV_ID_TYPE_SYS_SERIAL))) {
|
||||||
if (str_list_match_item(serial_str_list, idname)) {
|
if (str_list_match_item(serial_str_list, idname)) {
|
||||||
if (!(devl = dm_pool_zalloc(cmd->mem, sizeof(*devl))))
|
if (!(devl = dm_pool_zalloc(cmd->mem, sizeof(*devl))))
|
||||||
goto next_dev;
|
goto next_free;
|
||||||
if (!(id = zalloc(sizeof(struct dev_id))))
|
if (!(id = zalloc(sizeof(struct dev_id))))
|
||||||
goto next_dev;
|
goto next_free;
|
||||||
id->idtype = DEV_ID_TYPE_SYS_SERIAL;
|
id->idtype = DEV_ID_TYPE_SYS_SERIAL;
|
||||||
id->idname = (char *)idname;
|
id->idname = (char *)idname;
|
||||||
id->dev = dev;
|
id->dev = dev;
|
||||||
dm_list_add(&dev->ids, &id->list);
|
dm_list_add(&dev->ids, &id->list);
|
||||||
devl->dev = dev;
|
devl->dev = dev;
|
||||||
dm_list_add(devs, &devl->list);
|
dm_list_add(devs, &devl->list);
|
||||||
} else {
|
idname = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
next_free:
|
||||||
|
if (idname)
|
||||||
free((char *)idname);
|
free((char *)idname);
|
||||||
}
|
next_continue:
|
||||||
}
|
|
||||||
next_dev:
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
dev_iter_destroy(iter);
|
dev_iter_destroy(iter);
|
||||||
|
Loading…
Reference in New Issue
Block a user