From patchwork Tue Oct 22 06:38:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuan Can X-Patchwork-Id: 2002626 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=f1KRjXSA; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XZwFm1fdPz1xw0 for ; Sat, 26 Oct 2024 08:02:04 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 28E6260635; Fri, 25 Oct 2024 21:01:58 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id fFM89L2801WZ; Fri, 25 Oct 2024 21:01:57 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 2D4AE60BA2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1729890117; bh=G0+cTnqfkoCZ9jusaYTqH6vR9HVVkH3hA0gXF6LzMn8=; h=From:To:CC:Date:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=f1KRjXSA4wqbuOvWmvuFAsihHoSi82BfjnjrsWbpLNbfMFEblG/rxup1OzVYSU1wg KxJO94V76N7gVWm2WleSdSjjV4vDJVf3KMnobojBJqQrvh9Uw2425zWl/NLXwCjdlY MX5Yg4wXFXZeG1NZlRQQ49cchr8lP4N8ve7o2DDmK0vs9zgy+bb8bdhOHkPW+R7fTy gff0AR81/g/8F4UpLPFTmw/Fg4wol0mxqDwumV8VDJLaV4l+VFEjJq/DzoN9rMumJ+ bkASdL6Pik7hCm5znlx/5GK+2hmGvF6U0dB5WpFGhwsVx+i2V/a0Z/o8Rx6AN91zQQ 1L38s+B9AMo4g== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp3.osuosl.org (Postfix) with ESMTP id 2D4AE60BA2; Fri, 25 Oct 2024 21:01:57 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists1.osuosl.org (Postfix) with ESMTP id 6EE1C963 for ; Tue, 22 Oct 2024 07:01:32 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 4527F60699 for ; Tue, 22 Oct 2024 07:01:32 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id CxHVA3SyKfeE for ; Tue, 22 Oct 2024 07:01:31 +0000 (UTC) X-Greylist: delayed 1112 seconds by postgrey-1.37 at util1.osuosl.org; Tue, 22 Oct 2024 07:01:30 UTC DMARC-Filter: OpenDMARC Filter v1.4.2 smtp3.osuosl.org 1E8D3605C1 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 1E8D3605C1 Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=45.249.212.255; helo=szxga08-in.huawei.com; envelope-from=yuancan@huawei.com; receiver= Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by smtp3.osuosl.org (Postfix) with ESMTPS id 1E8D3605C1 for ; Tue, 22 Oct 2024 07:01:30 +0000 (UTC) Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4XXjHQ2LSqz1T94l; Tue, 22 Oct 2024 14:40:50 +0800 (CST) Received: from dggpeml500024.china.huawei.com (unknown [7.185.36.10]) by mail.maildlp.com (Postfix) with ESMTPS id 7623818007C; Tue, 22 Oct 2024 14:42:50 +0800 (CST) Received: from huawei.com (10.175.112.208) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Tue, 22 Oct 2024 14:42:49 +0800 From: Yuan Can To: , , , , , , , , , , , , , CC: Date: Tue, 22 Oct 2024 14:38:07 +0800 Message-ID: <20241022063807.37561-1-yuancan@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.175.112.208] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpeml500024.china.huawei.com (7.185.36.10) X-Mailman-Approved-At: Fri, 25 Oct 2024 21:01:54 +0000 X-Mailman-Original-Authentication-Results: smtp3.osuosl.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Subject: [Intel-wired-lan] [PATCH] igb: Fix potential invalid memory access in igb_init_module() X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" The pci_register_driver() can fail and when this happened, the dca_notifier needs to be unregistered, otherwise the dca_notifier can be called when igb fails to install, resulting to invalid memory access. Fixes: fe4506b6a2f9 ("igb: add DCA support") Signed-off-by: Yuan Can --- drivers/net/ethernet/intel/igb/igb_main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index f1d088168723..18284a838e24 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c @@ -637,6 +637,10 @@ static int __init igb_init_module(void) dca_register_notify(&dca_notifier); #endif ret = pci_register_driver(&igb_driver); +#ifdef CONFIG_IGB_DCA + if (ret) + dca_unregister_notify(&dca_notifier); +#endif return ret; }