Re: [PATCH net-next 4/5] net: mscc: ocelot: make entry_type a member of struct ocelot_multicast
From: Vladimir Oltean
Date: Sat Oct 31 2020 - 05:08:02 EST
On Fri, Oct 30, 2020 at 06:16:31PM -0700, Jakub Kicinski wrote:
> On Thu, 29 Oct 2020 04:27:37 +0200 Vladimir Oltean wrote:
> > + mc = devm_kzalloc(ocelot->dev, sizeof(*mc), GFP_KERNEL);
> > + if (!mc)
> > + return -ENOMEM;
> > +
> > + mc->entry_type = ocelot_classify_mdb(mdb->addr);
> > + ether_addr_copy(mc->addr, mdb->addr);
> > + mc->vid = vid;
> > +
> > + pgid = ocelot_mdb_get_pgid(ocelot, mc);
> >
> > if (pgid < 0) {
> > dev_err(ocelot->dev,
> > @@ -1038,24 +1044,19 @@ int ocelot_port_mdb_add(struct ocelot *ocelot, int port,
> > return -ENOSPC;
> > }
>
> Transitionally leaking mc here on pgid < 0
Is it a real leakage if it's allocated with devm though? At some point
it's still going to be freed. Nonetheless I agree there's still a lot of
work to do. Maybe I didn't choose the best moment to concentrate on a
new feature, should have focused on cleanup more beforehand, including a
change from devm to plain allocation/free of resources.