Re: [PATCH 3/9] bonding: Detect virtual bonding devices and create an ethernet device



On Tue, 2011-10-11 at 09:00 -0500, Dan Williams wrote:
> On Fri, 2011-09-23 at 14:52 +0200, Thomas Graf wrote:

> >  typedef struct {
> >  	GUdevClient *client;
> > @@ -458,9 +459,17 @@ device_creator (NMUdevManager *manager,
> >  	}
> >  
> >  	if (!driver) {
> > -		if (g_str_has_prefix (ifname, "easytether")) {
> > +		char *type;
> > +
> > +		type = nm_system_get_link_type (ifname);
> > +		if (type) {
> > +			if (g_strcmp0 (type, "bond") == 0)
> > +				driver = "bonding";
> 
> Don't we need to free 'type' here?  If we want to avoid this we could
> make nm_system_get_link_type() return an enum that we convert inside the
> function too (freeing the value there instead of making callers do it).
> Maybe not worth it, but might help prevent leaks later.

Good catch. I guess returning the string itself is more flexible but
adds the risk of introducing leaks. I'd rather fix the leak here and
stay flexible in this case.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]