# Re: \[PATCH net-next v2 03/12\] net: dpaa2-eth: add support for multiple buffer pools per DPNI

- From: Ioana Ciornei \<ioana.ciornei@nxp.com\>
- Date: 2022-09-27 13:38:00 
- List: netdev
- Page: https://ratatoskr.run/netdev/2022/09/7819367
- Thread: https://ratatoskr.run/netdev/2022/09/7818710/t.md

```text
On Tue, Sep 27, 2022 at 02:47:37PM +0200, Paolo Abeni wrote:
> On Fri, 2022-09-23 at 18:45 +0300, Ioana Ciornei wrote:
> > From: Robert-Ionut Alexa <redacted>
> > 
> > This patch allows the configuration of multiple buffer pools associated
> > with a single DPNI object, each distinct DPBP object not necessarily
> > shared among all queues.
> > The user can interogate both the number of buffer pools and the buffer
> > count in each buffer pool by using the .get_ethtool_stats() callback.
> > 
> > Signed-off-by: Robert-Ionut Alexa <redacted>
> > Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
> > ---
> > Changes in v2:
> >  - Export dpaa2_eth_allocate_dpbp/dpaa2_eth_free_dpbp in this patch to
> >    avoid a build warning. The functions will be used in next patches.
> > 

(...)

> > -/* Allocate and configure one buffer pool for each interface */
> > -static int dpaa2_eth_setup_dpbp(struct dpaa2_eth_priv *priv)
> > +/* Allocate and configure a buffer pool */
> > +struct dpaa2_eth_bp *dpaa2_eth_allocate_dpbp(struct dpaa2_eth_priv *priv)
> >  {
> > -	int err;
> > -	struct fsl_mc_device *dpbp_dev;
> >  	struct device *dev = priv->net_dev->dev.parent;
> > +	struct fsl_mc_device *dpbp_dev;
> >  	struct dpbp_attr dpbp_attrs;
> > +	struct dpaa2_eth_bp *bp;
> > +	int err;
> >  
> >  	err = fsl_mc_object_allocate(to_fsl_mc_device(dev), FSL_MC_POOL_DPBP,
> >  				     &dpbp_dev);
> > @@ -3219,12 +3244,16 @@ static int dpaa2_eth_setup_dpbp(struct dpaa2_eth_priv *priv)
> >  			err = -EPROBE_DEFER;
> >  		else
> >  			dev_err(dev, "DPBP device allocation failed\n");
> > -		return err;
> > +		return ERR_PTR(err);
> >  	}
> >  
> > -	priv->dpbp_dev = dpbp_dev;
> > +	bp = kzalloc(sizeof(*bp), GFP_KERNEL);
> > +	if (!bp) {
> > +		err = -ENOMEM;
> > +		goto err_alloc;
> > +	}
> 
> It looks like 'bp' is leaked on later error paths.
> 

Yes, I missed this.

Thanks!
```
