Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2657199pxj; Mon, 31 May 2021 07:33:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxeYG0pqKgXu5k7gBbEUsgjkpVESznQymwfejw6WBuLxkp88yYrpkKx0MfqNBKsGZkyLVBU X-Received: by 2002:a05:6e02:1154:: with SMTP id o20mr17709583ill.248.1622471625935; Mon, 31 May 2021 07:33:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622471625; cv=none; d=google.com; s=arc-20160816; b=F5unKvT0KlGnA+F3etPRzQ0kycQdA6sKh3HkWovghwiWO8vWfqWw7uSoM12tR2ocxg gZqkCKVea/iNk5MLdugkOyp5kw57l0LEoasspxFjcM5BksmQHXcL7wRBijK20eWFS2Ie JuVgw7SA/dJuhCEoEIgAliZDp33MmmNG3is3epn2VAuT6/BDX2vhxVgfP5AmWH1QIOoZ Qair0thdKzoqjoj9GYvQJ+yIFp6OS5clmgoIT7QqOtTQIXXc9lEvsCWuKbFduQj1es06 OyA4KfwTq/R0T4Fco3kD7AlqHd7rrAa1gYFrS89/YWBqJ679uPSOjVL6d7p0IQvHU9c3 wWcA== 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=MaY82qPiGPk1Z51n2cLv28droWsiDCegUKL49I6Kwzc=; b=BuvNqZUNFwOu24wEQzrQdZXGhqN5ZHn/o5TTAM3TSvxVTYeqhnziqAxBweksa93pLF Z+nPnZrtFNXTJgUnmPeNL9SZkQvKCKxh9OeXyZZGjyYuPF0FANxYICFC8zU4te2qTGYM ViWlWetwbPOWyaDXgsDskzZ1OvFS7UNkX4vUhCFonNgakMz4vtgFhRcathMN59kOOIRW tv5OAaaSPMcEeJQsWVJ8VYqDttx4L0HEb8RazaOzZoaD/XMh199zFY5KBPVY5e63zG0A afEJiIW8rTl9zl2Qb1TN0gPDHoLYpM3J2CUdrFuHV8kYXhLIlj8znf5gYpTGOCG0cOGs xYCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=a64ifoQ+; 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 p16si4308753iov.2.2021.05.31.07.33.31; Mon, 31 May 2021 07:33:45 -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=a64ifoQ+; 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 S232866AbhEaOeK (ORCPT + 99 others); Mon, 31 May 2021 10:34:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:59814 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231848AbhEaNzQ (ORCPT ); Mon, 31 May 2021 09:55:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3E0DC6143E; Mon, 31 May 2021 13:34:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468048; bh=auPDlSkBHh/2qxmhAoXyu3jcfuFKyKBpO/M1guYP74M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a64ifoQ+VbWJRFJsHbJewTcYjQ8yH4RqsZhDwSt4iYzsET5NvJCIW2rsVu5mbWqvB 3t29czVB90n5kt7DBH/VvavPjpaJ60VH/cLRBlbreBF9d+VZUFmg8Ynfq7G38ONiJe FYMoB2nn+iR7WKVG6koKxO5vYuCzzKg3FmPeuDDg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Saeed Mahameed , Aya Levin , Tariq Toukan Subject: [PATCH 5.10 097/252] net/mlx5e: reset XPS on error flow if netdev isnt registered yet Date: Mon, 31 May 2021 15:12:42 +0200 Message-Id: <20210531130701.279525401@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130657.971257589@linuxfoundation.org> References: <20210531130657.971257589@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: Saeed Mahameed commit 77ecd10d0a8aaa6e4871d8c63626e4c9fc5e47db upstream. mlx5e_attach_netdev can be called prior to registering the netdevice: Example stack: ipoib_new_child_link -> ipoib_intf_init-> rdma_init_netdev-> mlx5_rdma_setup_rn-> mlx5e_attach_netdev-> mlx5e_num_channels_changed -> mlx5e_set_default_xps_cpumasks -> netif_set_xps_queue -> __netif_set_xps_queue -> kmalloc If any later stage fails at any point after mlx5e_num_channels_changed() returns, XPS allocated maps will never be freed as they are only freed during netdev unregistration, which will never happen for yet to be registered netdevs. Fixes: 3909a12e7913 ("net/mlx5e: Fix configuration of XPS cpumasks and netdev queues in corner cases") Signed-off-by: Saeed Mahameed Signed-off-by: Aya Levin Reviewed-by: Tariq Toukan Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -5385,6 +5385,11 @@ err_free_netdev: return NULL; } +static void mlx5e_reset_channels(struct net_device *netdev) +{ + netdev_reset_tc(netdev); +} + int mlx5e_attach_netdev(struct mlx5e_priv *priv) { const bool take_rtnl = priv->netdev->reg_state == NETREG_REGISTERED; @@ -5438,6 +5443,7 @@ err_cleanup_tx: profile->cleanup_tx(priv); out: + mlx5e_reset_channels(priv->netdev); set_bit(MLX5E_STATE_DESTROYING, &priv->state); cancel_work_sync(&priv->update_stats_work); return err; @@ -5455,6 +5461,7 @@ void mlx5e_detach_netdev(struct mlx5e_pr profile->cleanup_rx(priv); profile->cleanup_tx(priv); + mlx5e_reset_channels(priv->netdev); cancel_work_sync(&priv->update_stats_work); }