Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp10081842rwb; Fri, 25 Nov 2022 00:23:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf4wp+Uervzz1vt9dc23zevp5Oj0Qgz/dZh02qJQZCrpBxg8DqXIcdC++cP230Ndtwgg2Vn9 X-Received: by 2002:a05:6402:1015:b0:461:5f19:61da with SMTP id c21-20020a056402101500b004615f1961damr33598213edu.34.1669364610930; Fri, 25 Nov 2022 00:23:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669364610; cv=none; d=google.com; s=arc-20160816; b=esvinwf0T87hcUBGcpdNBGhd2aKExwWsf7vNMQ9kMc195HtxuXkaItsuw6tXor83We x0D7riPhIyEv7pNDC4n/t6bu1X6hdXenKGElBGggZtToq45fnb0H7Bh//iNGyAZiLn6C UJS1RwECVRjNF194iFlvSe+zaEG11QLvw708+vkLjfBi9glZoUk54k2PCMayHK/W18A8 c5BxXP4aZBi/HnvTiooaNJ8Fv+aJe3VV/FZ+HVKz+v+fqUoL/CaLmVJS1TzmPmFDqPBZ w9FDmqCGItIy6Gw1++KfT3gnUMcgVbt1zB6GaA+D3oS4Ifzc4Kgou8QBc1lCau4IMjty eY6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=PrzDgDZopwC9XNcysEL4fsooZp/6hfBDRWV6LFo8mfM=; b=au3z76bfeUpSpApz5aX87YiRLRv/niRfaF9cRrWz5K3fu0sbJYdF9pOaxVcQSlaPuq H92aVA1rQQES5vJuwoC4zuQH5xaWLeqv9pOcugdR2phj42MIMARngOCZ/7+6qfQJRTjD 4kS1dGqJJB0hWe/P0TsWG8FOAOh7UNs3qyZVPECOgJpNMymGP7kr8HUE3y+in0xKhjSv ReL7S2DSThHJm3a9IuMNZkrUMzP/QkdWCA8bEhaxdKabIfc3LI/cj3/iWlQTYQ7X/fqd 8VF+rUY2my3pKkPn/y4qkoJ1SbjmwmiUeTTU5nFHKs3pdYCxHCDWZR4eUaq37A+3f7KQ CVtQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i21-20020a1709064fd500b0078e063fc787si2789411ejw.433.2022.11.25.00.23.09; Fri, 25 Nov 2022 00:23:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229668AbiKYHp6 (ORCPT + 87 others); Fri, 25 Nov 2022 02:45:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229758AbiKYHpx (ORCPT ); Fri, 25 Nov 2022 02:45:53 -0500 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0DCF2F03F; Thu, 24 Nov 2022 23:45:52 -0800 (PST) Received: from canpemm500006.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4NJRjS6j9nz15Mr5; Fri, 25 Nov 2022 15:45:16 +0800 (CST) Received: from localhost.localdomain (10.175.104.82) by canpemm500006.china.huawei.com (7.192.105.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 25 Nov 2022 15:45:49 +0800 From: Ziyang Xuan To: , , , , , , , , CC: Subject: [PATCH net 2/2] octeontx2-pf: Fix a potential double free in otx2_sq_free_sqbs() Date: Fri, 25 Nov 2022 15:45:46 +0800 Message-ID: <047b210eb3b3a2e26703d8b0570a0a017789c169.1669361183.git.william.xuanziyang@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.104.82] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500006.china.huawei.com (7.192.105.130) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org otx2_sq_free_sqbs() will be called twice when goto "err_free_nix_queues" label in otx2_init_hw_resources(). The first calling is within otx2_free_sq_res() at "err_free_nix_queues" label, and the second calling is at later "err_free_sq_ptrs" label. In otx2_sq_free_sqbs(), If sq->sqb_ptrs[i] is not 0, the memory page it points to will be freed, and sq->sqb_ptrs[i] do not be assigned 0 after memory page be freed. If otx2_sq_free_sqbs() is called twice, the memory page pointed by sq->sqb_ptrs[i] will be freeed twice. To fix the bug, assign 0 to sq->sqb_ptrs[i] after memory page be freed. Fixes: caa2da34fd25 ("octeontx2-pf: Initialize and config queues") Signed-off-by: Ziyang Xuan --- drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c index 9e10e7471b88..5a25fe51d102 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c @@ -1146,6 +1146,7 @@ void otx2_sq_free_sqbs(struct otx2_nic *pfvf) DMA_FROM_DEVICE, DMA_ATTR_SKIP_CPU_SYNC); put_page(virt_to_page(phys_to_virt(pa))); + sq->sqb_ptrs[sqb] = 0; } sq->sqb_count = 0; } -- 2.25.1