[CRIU] [PATCH] irmap: don't leak irmap objects in --irmap-scan-path

Tycho Andersen tycho.andersen at canonical.com
Tue Sep 22 12:13:01 PDT 2015


On Tue, Sep 22, 2015 at 09:47:07PM +0300, Pavel Emelyanov wrote:
> 
> > @@ -268,9 +268,14 @@ char *irmap_lookup(unsigned int s_dev, unsigned long i_ino)
> >  	list_for_each_entry(o, &opts.irmap_scan_paths, node) {
> >  		struct irmap *ir;
> >  
> > -		ir = xzalloc(sizeof(*ir));
> > -		if (!ir)
> > -			goto out;
> > +		if (!o->ir) {
> > +			ir = xzalloc(sizeof(*ir));
> > +			if (!ir)
> > +				goto out;
> > +			o->ir = ir;
> > +		} else {
> > +			ir = o->ir;
> 
> OK, and since we keep the ir on o all the time, is there any reason why
> we don't embed the struct irmap directly into the struct irmap_path_opt? :)

You mean just get rid of struct irmap_path_opt entirely? We could,
although we'd have to add a list_head to irmap, or just use realloc to
allocate the array or the argument list provided by --irmap-scan-path.
I'm fine with either of those, let me know which you prefer.

Tycho

> > +		}
> >  
> >  		ir->nr_kids = -1;
> >  		ir->path = o->path;
> 


More information about the CRIU mailing list