Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3929713imm; Mon, 8 Oct 2018 11:51:51 -0700 (PDT) X-Google-Smtp-Source: ACcGV60uLvkJ0QLDplsQkFc1WXC6ISjS8JFOSsPM02JMDsBuUaSnQSK33sCa3QOYqywiCaIJVezZ X-Received: by 2002:a63:f553:: with SMTP id e19-v6mr22169521pgk.417.1539024711289; Mon, 08 Oct 2018 11:51:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539024711; cv=none; d=google.com; s=arc-20160816; b=dKKk7eksQLDtasq7rNsAiRmnu3p6G3QwSXEtZcqGeH94X47G6aKY9fsy+EPeDkRRIA HL1jNvUUc0CIXoyJvG/sv5d2jABJMsgVio/2nlJji6TQETkCDXWA3/vSzjJCHiy/dADX BGX0uwhE7PrgASWbTb6bWHRW8guxULo9YaKtd4thheQ9B3/7pCqv/MXo881Vr1qmeOWK iCOBfxS8w12ofG5aE52wGjyYjM9Iv/P7OB72BVNU3218Y6zUqm4G+jCQh9AYU7Nh4X+l FQZN53H588biC4znp6uLBnRbwnt6NYy9h+jUKO/dJS4loCPgmmpqSbVRXarEv5KO/gmN y3pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=x0n4NRNHLKl5eCrifsjHHizBmm0HTIFlikxXbNlERrY=; b=WLTPgDwzq2uSrKo6biAXzMKYCokbw9gQONQA11yr5sfCbfILKvVEH/Goq7A1JQSXUX 1QC5cWRmfbmfJ/lDxAR7Sa3WR7UHzuRAZ3K73rJ6n47OjlBctk77LB9UoK/pmW9DVUfj HjczQ+8ihVcjrh7cZAf7Rsyl58OL4N+RBPyw/X0EpTFOYsBMGkp+ecJho1aML7ATzgVK 6DgwjXHw8xgbiVhnYwMWeaHwQ/hB2MRVOXQ2jQqE3aSmQEGiaLuCkxc/YSH5GnbMnWX+ Lrsfb5Hi8fprKUC0F0+uNqCS3ps+AxaLaT3IOimDYQezc1xpZE4bx1pb3sRM7BMKnROt Yc5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=g2W+GTgM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 23-v6si16732569pge.453.2018.10.08.11.51.36; Mon, 08 Oct 2018 11:51:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=g2W+GTgM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732339AbeJICEf (ORCPT + 99 others); Mon, 8 Oct 2018 22:04:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:54428 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731723AbeJICEe (ORCPT ); Mon, 8 Oct 2018 22:04:34 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AF57F204FD; Mon, 8 Oct 2018 18:51:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539024687; bh=rh+t9czMGs+SuL5ev3tQvQN+M1ESZDi9dRhSlsWmzm4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g2W+GTgMT7UhRImTQMZmdqWPu45mMjNV9AerViyfrXUUpwP6tf1b3JuvQd4Ju7DtY XFnHb8Cub5Is2WOKjJU7oBxvJ/0Y2eI+8Kx7xw816ybgR9wrs0KtsN+8SaAaZNrXed 3p42R447NXuCW2/NQixzUifvXqkmCYCtyf5aLjPA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Netanel Belgazal , "David S. Miller" , Sasha Levin Subject: [PATCH 4.18 122/168] net: ena: fix missing lock during device destruction Date: Mon, 8 Oct 2018 20:31:42 +0200 Message-Id: <20181008175624.688478781@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181008175620.043587728@linuxfoundation.org> References: <20181008175620.043587728@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Netanel Belgazal [ Upstream commit 944b28aa2982b4590d4d4dfc777cf85135dca2c0 ] acquire the rtnl_lock during device destruction to avoid using partially destroyed device. ena_remove() shares almost the same logic as ena_destroy_device(), so use ena_destroy_device() and avoid duplications. Signed-off-by: Netanel Belgazal Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/amazon/ena/ena_netdev.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c @@ -3420,24 +3420,18 @@ static void ena_remove(struct pci_dev *p unregister_netdev(netdev); - /* Reset the device only if the device is running. */ + /* If the device is running then we want to make sure the device will be + * reset to make sure no more events will be issued by the device. + */ if (test_bit(ENA_FLAG_DEVICE_RUNNING, &adapter->flags)) - ena_com_dev_reset(ena_dev, adapter->reset_reason); + set_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags); - ena_free_mgmnt_irq(adapter); - - ena_disable_msix(adapter); + rtnl_lock(); + ena_destroy_device(adapter, true); + rtnl_unlock(); free_netdev(netdev); - ena_com_mmio_reg_read_request_destroy(ena_dev); - - ena_com_abort_admin_commands(ena_dev); - - ena_com_wait_for_abort_completion(ena_dev); - - ena_com_admin_destroy(ena_dev); - ena_com_rss_destroy(ena_dev); ena_com_delete_debug_area(ena_dev);