[dm-devel] [PATCH v3 22/29] multipath: fix leaks in check_path_valid()

Martin Wilck mwilck at suse.com
Thu Dec 17 09:54:05 UTC 2020


On Wed, 2020-12-16 at 21:34 -0600, Benjamin Marzinski wrote:
> On Wed, Dec 16, 2020 at 07:17:01PM +0100, mwilck at suse.com wrote:
> > 
> >  
> >  	pp = alloc_path();
> >  	if (!pp)
> > @@ -665,13 +666,17 @@ check_path_valid(const char *name, struct
> > config *conf, bool is_uevent)
> >  	if (store_path(pathvec, pp) != 0) {
> 
> This will double-free the path, once here and again in cleanup.

argh, thanks - especially dumb with comment below :-/

> >  		free_path(pp);
> >  		goto fail;
> > +	} else {
> > +		/* make sure path isn't freed twice */
> > +		wwid = pp->wwid;
> > +		pp = NULL;
> >  	}
> > 
> ...
> > +
> > +cleanup:
> > +	if (pp != NULL)
> 
> shouldn't this be free_path(pp)

Absolutely. I'll resend this one. As everything else is reviewed now,
I'll just resubmit this one.

Martin





More information about the dm-devel mailing list