Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1648062pxy; Mon, 2 Aug 2021 07:03:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJgFpWG6kRS5izkRb0hX3+vPO7sJvoFRut2PJ9gIHJ9knkislrMPr64OukfjarY/0v5ERH X-Received: by 2002:a5d:85cf:: with SMTP id e15mr2716231ios.208.1627912995586; Mon, 02 Aug 2021 07:03:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627912995; cv=none; d=google.com; s=arc-20160816; b=UEJlxvhVZXh//dShXz7zy/93GfoYAhIX3L+oN3/0HM3r1trUMHrjpddrasCSq7hJ4f m0/OwrckNb0Zd0I8Xpw7Di8xJiz9bXq8bck3nt706p6QJlw0mzovaU29uTrh8fvMmOfX xSWFJIMuOUxXFSS5T83MD3sXUJblShlzhUvbppS68OwXpQC4z6N4zYwxFZCx4NgoQx4f 8/utSuTQDFLuGQqk6B92WMkgS2p3S+Ts7m1eI97Y8FH13PKct5PAyaw6mlqVIs+GaxY7 1rBpbfU+UHmd26XlDrpgbJ3TTouwWtAzqhigOovNgE1TpUyVNyZe+cm6yTFpigTsP+oK fqvA== 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=o8lTU7hn52Qmjrtt725zJUK5OjeDGGS0a2pbzsU+zuQ=; b=u7C9SMZPDJOil8XwMCKXkZP/64IKIJNeWCxa+uOJj2PuzCYFruIa0s6ID8dz6U3T/d 64XFjT3jrafPTAip3VnkxDUAEK7TqK/2t+Sacrsc/bUbS8td9m1JA8LlWGhe0xrQGrBH zeuwdY8zIBcxBY8ySMecEdtbmveC0fg4xzQAShyRvkaJ2NThQlWynIIf5nWwcI/0p3Vj /GQJSQ2MAF1P1VVnt0SXjpM6NiE+58W2fv9RqE0NV56DPI2EufRV4ghHQtNn+KfXNLmB wP1plOwxf8t0S6zPP23rVoDCy65pvO3ARKxJuGmFEpdShg/gM72TDgieNpZfpyHFOI2b VYIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EKXIWTvC; 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 c126si212149iof.49.2021.08.02.07.03.04; Mon, 02 Aug 2021 07:03:15 -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=EKXIWTvC; 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 S235423AbhHBOBB (ORCPT + 99 others); Mon, 2 Aug 2021 10:01:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:33500 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236138AbhHBNzA (ORCPT ); Mon, 2 Aug 2021 09:55:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2EFF661101; Mon, 2 Aug 2021 13:53:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627912406; bh=9eraPd7F0GpE6e0FfPsLMF2EuL8kWXIqoMRRAsaVHqY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EKXIWTvCZ9EsrF8EyK09Wv/kJ9xg4W5LFH2QL9ZekCoHlccipKNE7p93qKa4biZVi UdECTjBxelObgPaNuwiKUi8yhGJOqHN4WEH6eh+KvrN3OjWpePeJycd2TdnWmK09Ur 0rWC5T4NnLJbBW+bkEI2fitEjGyU5vdka11IEykE= 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.10 45/67] octeontx2-pf: Fix interface down flag on error Date: Mon, 2 Aug 2021 15:45:08 +0200 Message-Id: <20210802134340.561715991@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210802134339.023067817@linuxfoundation.org> References: <20210802134339.023067817@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 662fb80dbb9d..c6d408de0605 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c @@ -230,15 +230,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); @@ -342,7 +341,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 9fef9be015e5..044a5b1196ac 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c @@ -1592,6 +1592,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, @@ -1619,6 +1620,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