LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: YueHaibing <yuehaibing@huawei.com>,
	"David S . Miller" <davem@davemloft.net>,
	Sasha Levin <sashal@kernel.org>,
	netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 4.4 02/92] cxgb4: Fix error path in cxgb4_init_module
Date: Wed, 22 May 2019 15:29:57 -0400	[thread overview]
Message-ID: <20190522193127.27079-2-sashal@kernel.org> (raw)
In-Reply-To: <20190522193127.27079-1-sashal@kernel.org>

From: YueHaibing <yuehaibing@huawei.com>

[ Upstream commit a3147770bea76c8dbad73eca3a24c2118da5e719 ]

BUG: unable to handle kernel paging request at ffffffffa016a270
PGD 3270067 P4D 3270067 PUD 3271063 PMD 230bbd067 PTE 0
Oops: 0000 [#1
CPU: 0 PID: 6134 Comm: modprobe Not tainted 5.1.0+ #33
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.9.3-0-ge2fc41e-prebuilt.qemu-project.org 04/01/2014
RIP: 0010:atomic_notifier_chain_register+0x24/0x60
Code: 1f 80 00 00 00 00 55 48 89 e5 41 54 49 89 f4 53 48 89 fb e8 ae b4 38 01 48 8b 53 38 48 8d 4b 38 48 85 d2 74 20 45 8b 44 24 10 <44> 3b 42 10 7e 08 eb 13 44 39 42 10 7c 0d 48 8d 4a 08 48 8b 52 08
RSP: 0018:ffffc90000e2bc60 EFLAGS: 00010086
RAX: 0000000000000292 RBX: ffffffff83467240 RCX: ffffffff83467278
RDX: ffffffffa016a260 RSI: ffffffff83752140 RDI: ffffffff83467240
RBP: ffffc90000e2bc70 R08: 0000000000000000 R09: 0000000000000001
R10: 0000000000000000 R11: 00000000014fa61f R12: ffffffffa01c8260
R13: ffff888231091e00 R14: 0000000000000000 R15: ffffc90000e2be78
FS:  00007fbd8d7cd540(0000) GS:ffff888237a00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffffffa016a270 CR3: 000000022c7e3000 CR4: 00000000000006f0
Call Trace:
 register_inet6addr_notifier+0x13/0x20
 cxgb4_init_module+0x6c/0x1000 [cxgb4
 ? 0xffffffffa01d7000
 do_one_initcall+0x6c/0x3cc
 ? do_init_module+0x22/0x1f1
 ? rcu_read_lock_sched_held+0x97/0xb0
 ? kmem_cache_alloc_trace+0x325/0x3b0
 do_init_module+0x5b/0x1f1
 load_module+0x1db1/0x2690
 ? m_show+0x1d0/0x1d0
 __do_sys_finit_module+0xc5/0xd0
 __x64_sys_finit_module+0x15/0x20
 do_syscall_64+0x6b/0x1d0
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

If pci_register_driver fails, register inet6addr_notifier is
pointless. This patch fix the error path in cxgb4_init_module.

Fixes: b5a02f503caa ("cxgb4 : Update ipv6 address handling api")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index a3e1498ca67ce..3b96622de8ff2 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -5061,15 +5061,24 @@ static int __init cxgb4_init_module(void)
 
 	ret = pci_register_driver(&cxgb4_driver);
 	if (ret < 0)
-		debugfs_remove(cxgb4_debugfs_root);
+		goto err_pci;
 
 #if IS_ENABLED(CONFIG_IPV6)
 	if (!inet6addr_registered) {
-		register_inet6addr_notifier(&cxgb4_inet6addr_notifier);
-		inet6addr_registered = true;
+		ret = register_inet6addr_notifier(&cxgb4_inet6addr_notifier);
+		if (ret)
+			pci_unregister_driver(&cxgb4_driver);
+		else
+			inet6addr_registered = true;
 	}
 #endif
 
+	if (ret == 0)
+		return ret;
+
+err_pci:
+	debugfs_remove(cxgb4_debugfs_root);
+
 	return ret;
 }
 
-- 
2.20.1


  reply	other threads:[~2019-05-22 19:34 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-22 19:29 [PATCH AUTOSEL 4.4 01/92] gfs2: Fix lru_count going negative Sasha Levin
2019-05-22 19:29 ` Sasha Levin [this message]
2019-05-22 19:29 ` [PATCH AUTOSEL 4.4 03/92] mmc: core: Verify SD bus width Sasha Levin
2019-05-22 19:29 ` [PATCH AUTOSEL 4.4 04/92] powerpc/boot: Fix missing check of lseek() return value Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 05/92] ASoC: imx: fix fiq dependencies Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 06/92] spi: pxa2xx: fix SCR (divisor) calculation Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 07/92] brcm80211: potential NULL dereference in brcmf_cfg80211_vndr_cmds_dcmd_handler() Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 08/92] rtc: 88pm860x: prevent use-after-free on device remove Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 09/92] w1: fix the resume command API Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 10/92] dmaengine: pl330: _stop: clear interrupt status Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 11/92] mac80211/cfg80211: update bss channel on channel switch Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 12/92] driver core: platform: Fix the usage of platform device name(pdev->name) Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 13/92] ASoC: fsl_sai: Update is_slave_mode with correct value Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 14/92] mwifiex: prevent an array overflow Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 15/92] net: cw1200: fix a NULL pointer dereference Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 16/92] at76c50x-usb: Don't register led_trigger if usb_register_driver failed Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 17/92] ssb: Fix possible NULL pointer dereference in ssb_host_pcmcia_exit Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 18/92] bcache: return error immediately in bch_journal_replay() Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 19/92] bcache: fix failure in journal relplay Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 20/92] bcache: add failure check to run_cache_set() for journal replay Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 21/92] bcache: avoid clang -Wunintialized warning Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 22/92] RDMA/cma: Consider scope_id while binding to ipv6 ll address Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 23/92] x86/build: Move _etext to actual end of .text Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 24/92] smpboot: Place the __percpu annotation correctly Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 25/92] x86/mm: Remove in_nmi() warning from 64-bit implementation of vmalloc_fault() Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 26/92] mm/uaccess: Use 'unsigned long' to placate UBSAN warnings on older GCC versions Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 27/92] HID: logitech-hidpp: use RAP instead of FAP to get the protocol version Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 28/92] pinctrl: pistachio: fix leaked of_node references Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 29/92] dmaengine: at_xdmac: remove BUG_ON macro in tasklet Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 30/92] media: coda: clear error return value before picture run Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 31/92] media: ov6650: Move v4l2_clk_get() to ov6650_video_probe() helper Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 32/92] media: au0828: stop video streaming only when last user stops Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190522193127.27079-2-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=yuehaibing@huawei.com \
    --subject='Re: [PATCH AUTOSEL 4.4 02/92] cxgb4: Fix error path in cxgb4_init_module' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).