Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp637773iob; Thu, 12 May 2022 01:04:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrQLR2gjJkA8So2QMnL0lfRm/kufJnTtFuguskCYx8rRb6Bf8KNwpSvWt0mdTWgQPd9UZy X-Received: by 2002:a05:6402:335:b0:425:e3e0:5a90 with SMTP id q21-20020a056402033500b00425e3e05a90mr33388137edw.14.1652342675401; Thu, 12 May 2022 01:04:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652342675; cv=none; d=google.com; s=arc-20160816; b=fMCdCaL63nE2H3sjYgItOEKWJE2LpxMYGMzDOt0g+ZX68TKgSYkc4GUUYyqmX+eohE 5mGOEzkGsEC3IWaK0L+te8mJR7VDEwTkGKApHNcQ/CEhK5+j81/aAeUxHNLRv3eISpDT oVKdJT6IS13S/gL/VFedslMgGm/oRuNoebP5ezm0iP7oVeje5gw82LzjKrr9ywMjYqcX dXJu/wckunDTghgCk4oKisMC4ZyWZnj/AhkE+S/v/HaSZ7923B1VbpS6y8lirzcb6HOE rgTizUhG1FX7m3Zvvfl1O1XR4bw2ZOQ8b7YbJYnEh8+15aPAjfGcjtWS8e9kY5Uyd060 64VQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=ZWpuNsEuCQnNLYHchb1F6h3K5tYphTgV7TJMlesBZk0=; b=EvaxfUoJq41o9jEWyfTyZrbsAOW5TgbdoGTbUlb1fZxLGtwyjgyMiwqMRhHf5GYlRn UU1rRbFDOJEaMXev+measc9Zg+Supl46o8DTX8+/XaJ9g0Dyr8WbW83ncyJR+cFdOmbA MZfJXR9jGmq9CIT4vzTu6QNWJ6oNKcxdSTM5fdSGvEoFaMg8X6iQeAy438aaY6eAzOv7 w3elkBk6E32d7XDM1QaGI1nC2zpQJtVXtgvd22hGQLjPKb+j3kIEiO9o+ZHBBVvfHlEy /s8nvIA0I/7p7YgkVHGeVLEZn8f4r10c4lHdxPj8VgDzh6REzW8hYD9lUfqROcGqDcgo 7G1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@microchip.com header.s=mchp header.b=OYQJXxRh; 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=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lb13-20020a170907784d00b006f4cebf2c1bsi4916662ejc.806.2022.05.12.01.04.09; Thu, 12 May 2022 01:04:35 -0700 (PDT) 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; dkim=fail header.i=@microchip.com header.s=mchp header.b=OYQJXxRh; 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=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347853AbiEKUhm (ORCPT + 99 others); Wed, 11 May 2022 16:37:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347555AbiEKUhl (ORCPT ); Wed, 11 May 2022 16:37:41 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9B1E2BB03; Wed, 11 May 2022 13:37:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1652301458; x=1683837458; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=ct8k43enuOkoow9AJvOHfRIKrB74EgiEykFuu2k4yEo=; b=OYQJXxRh/V5zLB+jxDp3B4M3PD4CC53OpW6LI9/cd4vRtN9fxUtH0PoF 4J9+X5BQaSC4ZdxYEO0KSihSXdtVN1vLw7i9RWVoHmiTYfhEUZdR643g4 vM6S3giX5rZgrLwwmqucVFTKHXB4tc3Rk4fp0vM2XrgAlGIzPceLWafuM KCjMYgDTqIpyc7ZbNSFX2yj2I4ylbj3bubdB+uGj2OUdMjgEo7Jb00oLB 5FrPkwDAN4bWCoa+xd8XKr/GX2DX5mNVp/rcm1M3Y0dTD0EzWRwLoQVwd LO2edNqEAyRBmbQkDMQJFODlqFtXq3aZfRsqHHRUCSZ0A6hE7R15oBVm/ Q==; X-IronPort-AV: E=Sophos;i="5.91,218,1647327600"; d="scan'208";a="95415885" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 11 May 2022 13:37:37 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Wed, 11 May 2022 13:37:37 -0700 Received: from soft-dev3-1.microsemi.net (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Wed, 11 May 2022 13:37:35 -0700 From: Horatiu Vultur To: , CC: , , , , , Horatiu Vultur , Dan Carpenter Subject: [PATCH net-next] net: lan966x: Fix use of pointer after being freed Date: Wed, 11 May 2022 22:40:59 +0200 Message-ID: <20220511204059.2689199-1-horatiu.vultur@microchip.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 The smatch found the following warning: drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c:736 lan966x_fdma_reload() warn: 'rx_dcbs' was already freed. This issue can happen when changing the MTU on one of the ports and once the RX buffers are allocated and then the TX buffer allocation fails. In that case the RX buffers should not be restore. This fix this issue such that the RX buffers will not be restored if the TX buffers failed to be allocated. Fixes: 2ea1cbac267e2a ("net: lan966x: Update FDMA to change MTU.") Reported-by: Dan Carpenter Signed-off-by: Horatiu Vultur --- drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c index 9e2a7323eaf0..6dea7f8c1481 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c @@ -729,11 +729,11 @@ static int lan966x_fdma_reload(struct lan966x *lan966x, int new_mtu) return err; restore: lan966x->rx.dma = rx_dma; - lan966x->tx.dma = tx_dma; + lan966x->rx.dcbs = rx_dcbs; lan966x_fdma_rx_start(&lan966x->rx); restore_tx: - lan966x->rx.dcbs = rx_dcbs; + lan966x->tx.dma = tx_dma; lan966x->tx.dcbs = tx_dcbs; lan966x->tx.dcbs_buf = tx_dcbs_buf; -- 2.33.0