From patchwork Tue Nov 28 20:16:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 1869456 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Sftyl1KM5z23mS for ; Wed, 29 Nov 2023 07:16:47 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1r84VY-0000zs-Ry; Tue, 28 Nov 2023 20:16:36 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1r84VB-0000xW-L1 for kernel-team@lists.ubuntu.com; Tue, 28 Nov 2023 20:16:14 +0000 Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 37D383F044 for ; Tue, 28 Nov 2023 20:16:13 +0000 (UTC) Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-5bdd8eee498so5221771a12.0 for ; Tue, 28 Nov 2023 12:16:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701202571; x=1701807371; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IvqsqwuBvH8JXu5FW89vT8mzrgIeen2LF1DijqW8T9s=; b=FvklaJnwp4E+UDJ2kkr294FMfvRGgb7lAQ2Vf+yZG9khoIO3SvT6vyCqeSNeVxAkpk vL4XNwE/7KF+HlKUpPPcctBgTdXwiLJBT4FA346ExVca41wnsOOMIEkS4Y0F1aMdb9HT sSxlnWHLQdeyocObBfS6hjZUd9GvZuo5vbIeVqWxh7DZD2v3q14qM/iTSip2wb567aQY xAcORcEcJHz9GQzpNucCpc+wRESXVp78JVzEYW79BFBYAGd4g7aGmb7VZ7cbgRfvYZ5N RjI5sPyIZA550+TKm3OpjwTYg37nkFkmQfgVxJBIjXtZW4yhtU3MnKHEdXGeDAVrwcAF BPHw== X-Gm-Message-State: AOJu0YwqU2IDe9621mlgaPeoPYTJ+aprcQs5R/d11eUNPzzRzipTpqB4 mjPyn1xTjor0NajtIEj/ZqAIjGtpAidjjuzIb7ikk3IARS8NtjIKi5kmut476WrAVQsytxI+vsl tHz1zjCXy2wiag2z71dTqfWHCo2wj3L3Z/OAYoBfdzthtbXebig== X-Received: by 2002:a05:6a20:8f10:b0:18c:285f:c07c with SMTP id b16-20020a056a208f1000b0018c285fc07cmr14283340pzk.12.1701202571617; Tue, 28 Nov 2023 12:16:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IHsz9eDEQ51anPjmXS7kUjh974Ew09shvRX6xIbNlZFNOqUrtJfLhi0uqkFhAC+1Uzrtq9Teg== X-Received: by 2002:a05:6a20:8f10:b0:18c:285f:c07c with SMTP id b16-20020a056a208f1000b0018c285fc07cmr14283318pzk.12.1701202571304; Tue, 28 Nov 2023 12:16:11 -0800 (PST) Received: from smtp.gmail.com (174-045-099-030.res.spectrum.com. [174.45.99.30]) by smtp.gmail.com with ESMTPSA id w66-20020a636245000000b005ab46970aaasm9931359pgb.17.2023.11.28.12.16.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 12:16:11 -0800 (PST) From: Tim Gardner To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/3] hv_netvsc: Fix race of register_netdevice_notifier and VF register Date: Tue, 28 Nov 2023 13:16:05 -0700 Message-Id: <20231128201606.940649-3-tim.gardner@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231128201606.940649-1-tim.gardner@canonical.com> References: <20231128201606.940649-1-tim.gardner@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Haiyang Zhang BugLink: https://bugs.launchpad.net/bugs/2045069 If VF NIC is registered earlier, NETDEV_REGISTER event is replayed, but NETDEV_POST_INIT is not. Move register_netdevice_notifier() earlier, so the call back function is set before probing. Cc: stable@vger.kernel.org Fixes: e04e7a7bbd4b ("hv_netvsc: Fix a deadlock by getting rtnl lock earlier in netvsc_probe()") Reported-by: Dexuan Cui Signed-off-by: Haiyang Zhang Reviewed-by: Wojciech Drewek Reviewed-by: Dexuan Cui Signed-off-by: Paolo Abeni (cherry picked from commit 85520856466ed6bc3b1ccb013cddac70ceb437db) Signed-off-by: Tim Gardner --- drivers/net/hyperv/netvsc_drv.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index e247cd70e8a9..f62aea09adcc 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -2786,12 +2786,17 @@ static int __init netvsc_drv_init(void) } netvsc_ring_bytes = ring_size * PAGE_SIZE; + register_netdevice_notifier(&netvsc_netdev_notifier); + ret = vmbus_driver_register(&netvsc_drv); if (ret) - return ret; + goto err_vmbus_reg; - register_netdevice_notifier(&netvsc_netdev_notifier); return 0; + +err_vmbus_reg: + unregister_netdevice_notifier(&netvsc_netdev_notifier); + return ret; } MODULE_LICENSE("GPL");