lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Thu, 23 Jul 2015 12:24:05 +0200
From:	Lucas Stach <l.stach@...gutronix.de>
To:	Duan Andy <fugang.duan@...escale.com>
Cc:	"David S. Miller" <davem@...emloft.net>,
	"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
	Li Frank <Frank.Li@...escale.com>,
	"kernel@...gutronix.de" <kernel@...gutronix.de>,
	"patchwork-lst@...gutronix.de" <patchwork-lst@...gutronix.de>
Subject: Re: [PATCH v2 1/2] net: fec: use managed DMA API functions to
 allocate BD ring

Am Mittwoch, den 22.07.2015, 01:55 +0000 schrieb Duan Andy:
> From: Lucas Stach <l.stach@...gutronix.de> Sent: Tuesday, July 21, 2015 11:11 PM
> > To: David S. Miller
> > Cc: Duan Fugang-B38611; Li Frank-B20596; netdev@...r.kernel.org;
> > kernel@...gutronix.de; patchwork-lst@...gutronix.de
> > Subject: [PATCH v2 1/2] net: fec: use managed DMA API functions to
> > allocate BD ring
> > 
> > So it gets freed when the device is going away.
> > This fixes a DMA memory leak on driver probe() fail and driver remove().
> > 
> > Signed-off-by: Lucas Stach <l.stach@...gutronix.de>
> > ---
> > v2: Fix indentation of second line to fix alignment with opening bracket.
> > ---
> >  drivers/net/ethernet/freescale/fec_main.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/net/ethernet/freescale/fec_main.c
> > b/drivers/net/ethernet/freescale/fec_main.c
> > index 349365d85b92..a7f1bdf718f8 100644
> > --- a/drivers/net/ethernet/freescale/fec_main.c
> > +++ b/drivers/net/ethernet/freescale/fec_main.c
> > @@ -3142,8 +3142,8 @@ static int fec_enet_init(struct net_device *ndev)
> >  			fep->bufdesc_size;
> > 
> >  	/* Allocate memory for buffer descriptors. */
> > -	cbd_base = dma_alloc_coherent(NULL, bd_size, &bd_dma,
> > -				      GFP_KERNEL);
> > +	cbd_base = dmam_alloc_coherent(&fep->pdev->dev, bd_size, &bd_dma,
> > +				       GFP_KERNEL);
> >  	if (!cbd_base) {
> >  		return -ENOMEM;
> >  	}
> > --
> 
> Can you also replace the below position with dma_alloc_coherent() ?
>                 txq->tso_hdrs = dma_alloc_coherent(NULL,
>                                         txq->tx_ring_size * TSO_HEADER_SIZE,
>                                         &txq->tso_hdrs_dma,
>                                         GFP_KERNEL);
> 
> 
No, that one has an explicit free functions.
So using managed function would result in a double free in paths. We
might want to move those over to devm eventually to make the error
handling more robust, but that's clearly out of the scope of this patch.

Regards,
Lucas

-- 
Pengutronix e.K.             | Lucas Stach                 |
Industrial Linux Solutions   | http://www.pengutronix.de/  |

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ