Received: by 10.223.176.46 with SMTP id f43csp277718wra; Tue, 23 Jan 2018 20:54:13 -0800 (PST) X-Google-Smtp-Source: AH8x227moRjyO9tK+N+D+PSW0DQmlhfcXUv+lr7V1mCPjtclS2os9q9O/YQkP8yIfZKtq9HgarOP X-Received: by 2002:a17:902:481:: with SMTP id e1-v6mr5061177ple.228.1516769653655; Tue, 23 Jan 2018 20:54:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516769653; cv=none; d=google.com; s=arc-20160816; b=cu5iIifpCft4RLXNaXwKXGbWJ2CadwwtBvUJVqmz/XM8MkoZUBCX3fTimHhXS5erKn pdw/LsiO8xP4JEpDbb/I2BAV57Fxw3Q+cxHAs9I//m/y3BYj0FZaWUqVvMz4NiznebUT 1vvZpG51M/CbEMnGeG0N5d6G/oSIiY7QJ4i1KVZoz07gC61obC7KaVp2BhW5qhDMxTz+ OUDa8cCw6jwrfvInCiakKBW8EbPw/ptdPz1JZdQIsYrZnLt8IamF2SFSDeUPJq/3YvL1 MPxk7c4vbc3rodh1i0IZhpq7I6P3EsZ+JDef7GVYRYqqt+434v/RV+qZUZS03ZaMRQwd qBBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=Cu2b3mxjqHbiHfP9A1Nv1RXnLazXH8/q2rkHAB4QuTg=; b=l3W2lRxZ0Pexl9PDzKgpBEdTRoHH3oqKNnyO0oD5NxgfOCHyJ1bqDyf9LD/9g+rvqZ PxbXbCo+5ULbO2s+Q8Lg1CkKCwjFZajOP9TNj1wezKs643neu/w/42f7H2wi1CA/tenA jlPZoLAyTX9LoLVdtczWnAg39sxJ9syx/LwIx6dhrn1aDDCkq+f6NGRHBNfSVa8lYsyO 8F0yUpVEXggSm5CIX4/XHA8virYLwmMMgD+CRwDtj87qNR+iqFZK+AhQ81AlGJyRuhcL edzrz2eH5dDhu4GFpbIdcXvpw/xjZgUQr2BgIFBsrjeSQbNHXmphciuonR/8c8n78okf 7o6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=jlg2Isb7; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g7si2298987pfj.60.2018.01.23.20.54.00; Tue, 23 Jan 2018 20:54:13 -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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=jlg2Isb7; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932638AbeAXExM (ORCPT + 99 others); Tue, 23 Jan 2018 23:53:12 -0500 Received: from mail-sn1nam01on0120.outbound.protection.outlook.com ([104.47.32.120]:45079 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932433AbeAXEP7 (ORCPT ); Tue, 23 Jan 2018 23:15:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Cu2b3mxjqHbiHfP9A1Nv1RXnLazXH8/q2rkHAB4QuTg=; b=jlg2Isb7L/SsUjxT+TAuV1NSZaNoGWLVMmMignjEolj6x1ZbWMQrX9Rj1NiKq5tldpgR4yhvKRS/4Hxy3C1fWqAMF+/1TYsbZST5fymDQzvOHq9D/H63Uzj7kRLvfVvHXlcOuvUhPzQ/CYkc/+KvjGIp9scKCJbBj52zQNoaPM8= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1015.namprd21.prod.outlook.com (52.132.133.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.464.0; Wed, 24 Jan 2018 04:15:54 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::6485:b98:d15e:9da7]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::6485:b98:d15e:9da7%2]) with mapi id 15.20.0464.000; Wed, 24 Jan 2018 04:15:54 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Antoine Tenart , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 065/100] net: mvpp2: fix the txq_init error path Thread-Topic: [PATCH AUTOSEL for 4.14 065/100] net: mvpp2: fix the txq_init error path Thread-Index: AQHTlMnlcqyBSe9NBUC1B7B4HY46UA== Date: Wed, 24 Jan 2018 04:14:58 +0000 Message-ID: <20180124041414.32065-65-alexander.levin@microsoft.com> References: <20180124041414.32065-1-alexander.levin@microsoft.com> In-Reply-To: <20180124041414.32065-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB1015;6:4GjnPVBLSMmGZ/QfHBtw+eP4/J2vfqVgOpBz1JcPSeZPY98pACoBQ7j0qXfXUSZ1NdwKlVJ5ctJKcZkOnDRQlBygeXP9HEheBIekjsEPh0Vsp5A7XdhvCUcVvax/GmOMtok4uG6cH5XIEJ2SutjVV2TxAzUaQNcXabLFBCr40580rCqh5nxNhPvXJqCtPCyst90KydjBfIAgRtc+vmN9mKLqVHqW3VdTZZX2iAxd08U0YpyKSEEQEKrdfg8ER5REqEF1ezgtHhB+pPVBMs5Z6OUTqbhjbN2c7a8EvzLNu6kCiTBtOIZCh0wC9kr2DQNra+XjDJNN+Q3X6wBEXxyuuLCGW6hf7o0bjv//VQ0UVk8Y+KTiLMej8JikSJjOtNVz;5:uwsHJvHBk9Pj3juoSgKFR6qIbJPcZw0Tj8lyenmJWz9us+oNw6mrnFPr3YcNEMTlhrRe66pzQxuDRyJg8KYrUmCEWaDVoInCo19tWVAT2dHU36u2c+a16Dj+hnvfGlBEFUc/n9lyVUvbxfmDhVP42N+gCgluBFdxQ5d+LlaWfZg=;24:UHIsLUa3MOBXrTpc05AJyVDHJULqCK7udPmJtZdMvd2qlmuj/qs4Be2UDgtXGEtKZwJBN+E7huxxtY4EuTP4L1ABFzagqRZrKN3EjlqTrew=;7:0T5hIJy1RFD/ljMyq2T8Kf0nXGMUKf/4Qxx2JD6b49YW3kialXjYePnxDiI7oaiRpLif3OKNQIBC/Nv2huOhO+0QWUQr9g7YaqwAX7NJ5eBZwvzGWXc+pYLw5ANndrrXLcaHuD/EQbV7FVzklQjPyn3Kt8ox5Ik5ud2hKLc2qGTVOHXISwwYzwqnLVcmtbB/UxzK/XmRfLXKMwkXeiOF72koEeFdnWc/SZWIR8+nBBYeDHqXjaQNYaCHOMrXqjwD x-ms-office365-filtering-correlation-id: bae3cfda-a942-417f-7d3b-08d562e1298a x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(2017052603307)(7193020);SRVR:DM5PR2101MB1015; x-ms-traffictypediagnostic: DM5PR2101MB1015: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(58145275503218); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(6040501)(2401047)(5005006)(8121501046)(3002001)(10201501046)(3231046)(2400081)(944501161)(93006095)(93001095)(6055026)(61426038)(61427038)(6041288)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR2101MB1015;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1015; x-forefront-prvs: 056297E276 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(396003)(39380400002)(376002)(366004)(39860400002)(346002)(199004)(189003)(478600001)(106356001)(6512007)(53936002)(2900100001)(36756003)(102836004)(2950100002)(2501003)(10290500003)(97736004)(14454004)(81166006)(72206003)(8936002)(6486002)(1076002)(10090500001)(6346003)(26005)(54906003)(4326008)(575784001)(76176011)(99286004)(86362001)(3660700001)(105586002)(6116002)(8676002)(68736007)(22452003)(66066001)(25786009)(6506007)(5660300001)(305945005)(7736002)(3280700002)(5250100002)(2906002)(107886003)(86612001)(6436002)(316002)(81156014)(3846002)(110136005)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1015;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: 4i5dGnGc6YVq6syYFkLA8sA1D1Mb+f6g7E73pC8aYbge7TDJFwUFmsZUNjb1VvSl2LPG5d5KvKByl7uc3/m1oA== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: bae3cfda-a942-417f-7d3b-08d562e1298a X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Jan 2018 04:14:58.0496 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1015 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/net/ethernet/marvell/mvpp2.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/ma= rvell/mvpp2.c index fcf9ba5eb8d1..8044cfb0b667 100644 --- a/drivers/net/ethernet/marvell/mvpp2.c +++ b/drivers/net/ethernet/marvell/mvpp2.c @@ -5606,7 +5606,7 @@ static int mvpp2_txq_init(struct mvpp2_port *port, sizeof(*txq_pcpu->buffs), GFP_KERNEL); if (!txq_pcpu->buffs) - goto cleanup; + return -ENOMEM; =20 txq_pcpu->count =3D 0; txq_pcpu->reserved_num =3D 0; @@ -5619,26 +5619,10 @@ static int mvpp2_txq_init(struct mvpp2_port *port, &txq_pcpu->tso_headers_dma, GFP_KERNEL); if (!txq_pcpu->tso_headers) - goto cleanup; + return -ENOMEM; } =20 return 0; -cleanup: - for_each_present_cpu(cpu) { - txq_pcpu =3D 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; } =20 /* Free allocated TXQ resources */ --=20 2.11.0