Commit 97cb181c authored by Tycho Andersen's avatar Tycho Andersen Committed by Pavel Emelyanov

irmap: don't leak irmap objects in --irmap-scan-path

v2: use struct irmap directly in irmap_path_opt
Signed-off-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 6c62aa8a
......@@ -38,9 +38,11 @@ struct cg_root_opt {
*/
#define DEFAULT_GHOST_LIMIT (1 << 20)
struct irmap;
struct irmap_path_opt {
struct list_head node;
char *path;
struct irmap *ir;
};
struct cr_options {
......
......@@ -266,16 +266,7 @@ char *irmap_lookup(unsigned int s_dev, unsigned long i_ino)
* about them, hopefully they're more interesting than our hints.
*/
list_for_each_entry(o, &opts.irmap_scan_paths, node) {
struct irmap *ir;
ir = xzalloc(sizeof(*ir));
if (!ir)
goto out;
ir->nr_kids = -1;
ir->path = o->path;
c = irmap_scan(ir, s_dev, i_ino);
c = irmap_scan(o->ir, s_dev, i_ino);
if (c) {
pr_debug("\tScanned %s\n", c->path);
path = c->path;
......@@ -485,11 +476,18 @@ int irmap_scan_path_add(char *path)
{
struct irmap_path_opt *o;
o = xmalloc(sizeof(*o));
o = xzalloc(sizeof(*o));
if (!o)
return -1;
o->path = path;
o->ir = xzalloc(sizeof(*o->ir));
if (!o->ir) {
xfree(o);
return -1;
}
o->ir->path = path;
o->ir->nr_kids = -1;
list_add(&o->node, &opts.irmap_scan_paths);
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment