Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1659770pxy; Mon, 2 Aug 2021 07:16:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRLVietYlSTKl43FiZcQ4AktKCTErDY/wzqOVtvzXqErIKOiu77JTTNEbuMdMWaZA3v+sa X-Received: by 2002:a17:906:4917:: with SMTP id b23mr16247663ejq.468.1627913786324; Mon, 02 Aug 2021 07:16:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627913786; cv=none; d=google.com; s=arc-20160816; b=MMHz2u8QopEAizJ41+KzeeqYftEEvVBl0aTWUtcVj3MrjLYuROCcOXSPlN3bsrl+as 8SyvWrR07bhFawi6+OL9apJZS40XCOKrT507qfrZM+1KfGXRo48vDNJ/kuvsN/cQCpMd 6ZkE7xVyFVngld3yitukpgPCS9xUZz7bs9Eg/mLE8057ylhtNxfpfFHp0Bur4EgUe0Dh Cnl2+VpfPQiH+JSX/k2RHaM+Gnuipa6vEvd1xoK+4WVKaRBL24fLhbezw6MgK3u2vHlp ndNp+voKnEq0qRIX8CWxYwzzc8lheKlp7R/QVBsvbqzChCnV1bhQvXX/WHyTjHP7BuBB wG7w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+r2PgWaGQbkQ/QYAreI45Myg4MTjV4Alf9ie4lpljCk=; b=p2cDuVFTmfEnWqZPsqXZ3lcjP91UzLsE+rASl1nJNcCRC75vT2mMdH778h96PrWIWK lBTWDwSMjpraZrFJQTMFUGiGJG9YzoWZKLdV+NVAYa6iN2k9ygTtYEm8LkFmtGWmFyDu vQ76gaDWAt/GhqPxZihWDZ1ogjmvvG128O2ixjFXkeMb/oXpoaOkoxnnU3tXv6Al05VM RXhFqwcrKJA6ILU7X1eMpBf1Fx7BcVPDHv0E2MxK3IfUrr7/dXDJ3QUzvZMeMECskIDJ bNvlTcsqClFgQz0dTLEHUhyp2gXcPaghOUcSkV/KDu4nW7XE9g4R6671aj+nxFpz2IyT pojQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qpAhsC0D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m20si7158975edv.474.2021.08.02.07.16.03; Mon, 02 Aug 2021 07:16:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qpAhsC0D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238109AbhHBOKs (ORCPT + 99 others); Mon, 2 Aug 2021 10:10:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:48988 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235085AbhHBOBR (ORCPT ); Mon, 2 Aug 2021 10:01:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B34E5611CC; Mon, 2 Aug 2021 13:56:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627912590; bh=3LFOd4PwfknOxOLtsuVzLg1QZNOdncPJDeADEZJeLxQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qpAhsC0DbB1Ny+JNNoJw1/p/CT2yCT/ltSyIbTDcjePiWki2sDAvn+D6mhKzDReKa wA3E63ejizTzQuBB2n8dQ5ByJ0+fhb6nzhzA+bYIgwuAo6OKSci6Ei1MRIzMED5mSg HN0MNYl5pK4M3RZctp1f33Tj9vzjT1IDd1L8Z5XM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Geetha sowjanya , Sunil Kovvuri Goutham , "David S. Miller" , Sasha Levin Subject: [PATCH 5.13 062/104] octeontx2-pf: Fix interface down flag on error Date: Mon, 2 Aug 2021 15:44:59 +0200 Message-Id: <20210802134346.036098009@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210802134344.028226640@linuxfoundation.org> References: <20210802134344.028226640@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Geetha sowjanya [ Upstream commit 69f0aeb13bb548e2d5710a350116e03f0273302e ] In the existing code while changing the number of TX/RX queues using ethtool the PF/VF interface resources are freed and reallocated (otx2_stop and otx2_open is called) if the device is in running state. If any resource allocation fails in otx2_open, driver free already allocated resources and return. But again, when the number of queues changes as the device state still running oxt2_stop is called. In which we try to free already freed resources leading to driver crash. This patch fixes the issue by setting the INTF_DOWN flag on error and free the resources in otx2_stop only if the flag is not set. Fixes: 50fe6c02e5ad ("octeontx2-pf: Register and handle link notifications") Signed-off-by: Geetha sowjanya Signed-off-by: Sunil Kovvuri Goutham Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 7 +++---- drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 5 +++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c index 9d9a2e438acf..ae06eeeb5a45 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c @@ -292,15 +292,14 @@ static int otx2_set_channels(struct net_device *dev, err = otx2_set_real_num_queues(dev, channel->tx_count, channel->rx_count); if (err) - goto fail; + return err; pfvf->hw.rx_queues = channel->rx_count; pfvf->hw.tx_queues = channel->tx_count; pfvf->qset.cq_cnt = pfvf->hw.tx_queues + pfvf->hw.rx_queues; -fail: if (if_up) - dev->netdev_ops->ndo_open(dev); + err = dev->netdev_ops->ndo_open(dev); netdev_info(dev, "Setting num Tx rings to %d, Rx rings to %d success\n", pfvf->hw.tx_queues, pfvf->hw.rx_queues); @@ -404,7 +403,7 @@ static int otx2_set_ringparam(struct net_device *netdev, qs->rqe_cnt = rx_count; if (if_up) - netdev->netdev_ops->ndo_open(netdev); + return netdev->netdev_ops->ndo_open(netdev); return 0; } diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c index 03004fdac0c6..2af50250d13c 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c @@ -1648,6 +1648,7 @@ int otx2_open(struct net_device *netdev) err_tx_stop_queues: netif_tx_stop_all_queues(netdev); netif_carrier_off(netdev); + pf->flags |= OTX2_FLAG_INTF_DOWN; err_free_cints: otx2_free_cints(pf, qidx); vec = pci_irq_vector(pf->pdev, @@ -1675,6 +1676,10 @@ int otx2_stop(struct net_device *netdev) struct otx2_rss_info *rss; int qidx, vec, wrk; + /* If the DOWN flag is set resources are already freed */ + if (pf->flags & OTX2_FLAG_INTF_DOWN) + return 0; + netif_carrier_off(netdev); netif_tx_stop_all_queues(netdev); -- 2.30.2