Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932365AbdIRJsw (ORCPT ); Mon, 18 Sep 2017 05:48:52 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:55310 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754004AbdIRJNA (ORCPT ); Mon, 18 Sep 2017 05:13:00 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Florian Fainelli , "David S. Miller" Subject: [PATCH 4.12 13/52] net: systemport: Free DMA coherent descriptors on errors Date: Mon, 18 Sep 2017 11:11:07 +0200 Message-Id: <20170918091018.587475922@linuxfoundation.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170918091016.620101134@linuxfoundation.org> References: <20170918091016.620101134@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1331 Lines: 36 4.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Florian Fainelli [ Upstream commit c2062ee3d9615828109ffe8089fbf69bed394d05 ] In case bcm_sysport_init_tx_ring() is not able to allocate ring->cbs, we would return with an error, and call bcm_sysport_fini_tx_ring() and it would see that ring->cbs is NULL and do nothing. This would leak the coherent DMA descriptor area, so we need to free it on error before returning. Reported-by: Eric Dumazet Fixes: 80105befdb4b ("net: systemport: add Broadcom SYSTEMPORT Ethernet MAC driver") Signed-off-by: Florian Fainelli Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/broadcom/bcmsysport.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/net/ethernet/broadcom/bcmsysport.c +++ b/drivers/net/ethernet/broadcom/bcmsysport.c @@ -1342,6 +1342,8 @@ static int bcm_sysport_init_tx_ring(stru ring->cbs = kcalloc(size, sizeof(struct bcm_sysport_cb), GFP_KERNEL); if (!ring->cbs) { + dma_free_coherent(kdev, sizeof(struct dma_desc), + ring->desc_cpu, ring->desc_dma); netif_err(priv, hw, priv->netdev, "CB allocation failed\n"); return -ENOMEM; }