Received: by 10.223.176.5 with SMTP id f5csp988997wra; Fri, 2 Feb 2018 09:19:00 -0800 (PST) X-Google-Smtp-Source: AH8x224r3C7Zf3cfVSZRrJ4q06ZJz/iK9FL84d2STUfMGNgJMBPyzv0UDu/BgacF5VlCJa/5E/JX X-Received: by 10.98.153.197 with SMTP id t66mr562755pfk.142.1517591939964; Fri, 02 Feb 2018 09:18:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517591939; cv=none; d=google.com; s=arc-20160816; b=x7T6n/wTzr02+ZKPr+8Wk5kEEWgEdUMjABgVyIaVEuEyEqhLrsOvcSxM5xWq4cEEdN 8fE4YFFnyUaCdYx3dChNN1CKEe6FP1hdDJWg7jsn314dpzQnxylhNM+LzJa4Rivc9qsQ M3JDXdyVE5J8vcpvxtLgs4nGQmSo/RQRF0I0Ylrsk8k1zEVNaIZaSQzQSeFp+cgcVKAS L7rkNMxFV4KPyEkI+9GobGUeZ0tr4Uai52IlazKi5rSPPDC7WZd0ViNFSdPCIc7PWe8y idlPWC0Lsim89mTUJsnaz3TMHz/BXEEazdzyvbvyyPm2o+JwDrroWfv1klJsyl8tyvPL bmcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=dhJFYtmH6/I4Jk/zCeYN8tfcvE16CnwOBnGFatDMINk=; b=jzXCGLOo21H8+4IUIHJ3cW4b90f/QLV7TO5z1PTFHb4eX9WDa/ig6s+bAqBe1k3dfM vQew/B19ylQ0sJUStTKbbkCZMkZ+6LemrdSskOVVgOpbisGHlILH3AX1TKlYDBP3pkrn 9wzeNcf4xEBhi+6KvqQuKvhIhuk7pftYqqkbXS3zrYrfXWCKx75Cmz0IbM308lM1OsU5 APwYj0xVvXAMjVoCtw2JsP0OX1jv09yNWE8My4/YuTh/jOxic6lOnnGLJ8n/sBsVk86e +Zm2UNSUtgfyp9bjomm8IG1Lxxy8UUMP6jdDWejKQyoHtvcP8896xY0s2t691PcDK+PR NuSw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v81si638529pgb.570.2018.02.02.09.18.45; Fri, 02 Feb 2018 09:18:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753921AbeBBRSO (ORCPT + 99 others); Fri, 2 Feb 2018 12:18:14 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:38580 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753203AbeBBRLS (ORCPT ); Fri, 2 Feb 2018 12:11:18 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 81A7BF08; Fri, 2 Feb 2018 17:11:17 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Antoine Tenart , "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 093/156] net: mvpp2: fix the txq_init error path Date: Fri, 2 Feb 2018 17:57:54 +0100 Message-Id: <20180202140844.448045058@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140840.242829545@linuxfoundation.org> References: <20180202140840.242829545@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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Antoine Tenart [ Upstream commit ba2d8d887d962c2f790e6dc01b2fd25b4608720b ] When an allocation in the txq_init path fails, the allocated buffers end-up being freed twice: in the txq_init error path, and in txq_deinit. This lead to issues as txq_deinit would work on already freed memory regions: kernel BUG at mm/slub.c:3915! Internal error: Oops - BUG: 0 [#1] PREEMPT SMP This patch fixes this by removing the txq_init own error path, as the txq_deinit function is always called on errors. This was introduced by TSO as way more buffers are allocated. Fixes: 186cd4d4e414 ("net: mvpp2: software tso support") Signed-off-by: Antoine Tenart Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/marvell/mvpp2.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) --- a/drivers/net/ethernet/marvell/mvpp2.c +++ b/drivers/net/ethernet/marvell/mvpp2.c @@ -5597,7 +5597,7 @@ static int mvpp2_txq_init(struct mvpp2_p sizeof(*txq_pcpu->buffs), GFP_KERNEL); if (!txq_pcpu->buffs) - goto cleanup; + return -ENOMEM; txq_pcpu->count = 0; txq_pcpu->reserved_num = 0; @@ -5610,26 +5610,10 @@ static int mvpp2_txq_init(struct mvpp2_p &txq_pcpu->tso_headers_dma, GFP_KERNEL); if (!txq_pcpu->tso_headers) - goto cleanup; + return -ENOMEM; } return 0; -cleanup: - for_each_present_cpu(cpu) { - txq_pcpu = per_cpu_ptr(txq->pcpu, cpu); - kfree(txq_pcpu->buffs); - - dma_free_coherent(port->dev->dev.parent, - txq_pcpu->size * TSO_HEADER_SIZE, - txq_pcpu->tso_headers, - txq_pcpu->tso_headers_dma); - } - - dma_free_coherent(port->dev->dev.parent, - txq->size * MVPP2_DESC_ALIGNED_SIZE, - txq->descs, txq->descs_dma); - - return -ENOMEM; } /* Free allocated TXQ resources */