[ovs-dev] [add-remove v2 5/8] vswitchd: Support changing the type of a bridge port.

Ben Pfaff blp at nicira.com
Mon Oct 11 17:26:30 UTC 2010


On Fri, Oct 08, 2010 at 05:20:54PM -0700, Jesse Gross wrote:
> On Fri, Oct 1, 2010 at 4:48 PM, Ben Pfaff <blp at nicira.com> wrote:
> > +int
> > +ofproto_port_del(struct ofproto *ofproto, uint16_t odp_port)
> > +{
> > +    struct ofport *ofport = get_port(ofproto, odp_port);
> > +    const char *name = ofport ? (char *) ofport->opp.name : "<unknown>";
> > +    int error;
> > +
> > +    error = dpif_port_del(ofproto->dpif, odp_port);
> > +    if (error) {
> > +        VLOG_ERR("%s: failed to remove port %"PRIu16" (%s) interface (%s)",
> > +                 dpif_name(ofproto->dpif), odp_port, name, strerror(error));
> > +    } else if (ofport) {
> > +        char *devname = xstrdup(name);
> > +        update_port(ofproto, devname);
> > +        free(devname);
> 
> Why do we have to strdup name?  The argument to update_port() is const.

name comes from ofport->opp.name.  update_port() is going to destroy
ofport.  If update_port() happens to use its argument after ofport gets
destroyed, poof.  Probably, it wouldn't do that, but it makes me
nervous.

I'll add a comment.




More information about the dev mailing list