Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp463104yba; Wed, 15 May 2019 04:33:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqygT3I3CyRIlDC2hhlWejMVREOgfrvlgdNbQcgpNT7HZh4sgScjNbc9EuUal5O5CCEjhPK7 X-Received: by 2002:a17:902:9a81:: with SMTP id w1mr41606798plp.71.1557920001734; Wed, 15 May 2019 04:33:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557920001; cv=none; d=google.com; s=arc-20160816; b=cJGhSgPrBkbT8sFIEGPvPGMDUtQIgp/hj7gudKRyM4T4HmWcSoqiybJlrE4LDGrDMR 30je1cfx+IW2qX8c/tsBKTti9WswdrZJGOMAKko68wdW2SNkyDuYiVVkXA0zNccqfOXX 004zia7p7sSJcOwqIm9jdkBYOTAwBZNuks01A3/emqBZjQExh0yr+l72G71hrMIF+66V bQX8ettQ50xDUKZLEFbGU09bydQYxctuTxYj8hfNQXnXyKHGbmrZ6fsHQdWIJH9pR1Ca oLsRH4DIcbjHUphX48qlxlD35YcKpvu8lpO0IVVphG+pVEDvkSVU3YpQs7Eo2jp/C5Tf 23PA== 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=MtmlWBQXbDoJv0KqDALBitMr+0cOngHCce8DYdBm2u4=; b=JPC5OeLJLJumxGUUuHKQfri0YP4yPYXA4D4dhwFBTnj+AWFumAB4UGZ5WLuULbCcbT +aU/xktua2vKdGo5CwuWOoQLw12ntpJBRUQf+RCqBc9YW4m5dyMqZoC2Ym6Ei+i7YOgx ce66SyZrULQ2+ePJjOvd8TxIb9F7nFPna+3+uTWxZu3yMnU+jQTY+AXqPO+zwodkt9kJ B58zsqiPc6LuBXpKex+ZEREPto/KKrt4vpLbN2zPO2WaYwejIDQAMLwuMY9zgX3OaYf/ 5bZD322lw6JcLtOA6VTiJ/w7wPIs2KbZWMUxFHrYEBcRxAAnHgNqxJ9+SOP9ygMHJKB9 6/Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=e6qT5dyR; 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 31si1565368pli.242.2019.05.15.04.33.07; Wed, 15 May 2019 04:33:21 -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=e6qT5dyR; 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 S1732757AbfEOLaj (ORCPT + 99 others); Wed, 15 May 2019 07:30:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:42126 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732395AbfEOLae (ORCPT ); Wed, 15 May 2019 07:30:34 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 73AA020843; Wed, 15 May 2019 11:30:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557919833; bh=FbVYH8p85acccOz3zuFcc6oZMQvsRPlnhH0ItQSQmFs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e6qT5dyRAajrg9NSz0fSgkoCEvbWkSaTVzerJKJ1rE5h3/ZKz8Gj7ZI2SteE//eSy KN52Ur8ZV6d9+CDPL3q0goP3lrB4fopcmyFGFUYWSwrb1qId97BH1dsgtfr2RB0XKd jiXsXwhFMUK8tBbsL5i4ITZEICxQvXfQrblD1niQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, YueHaibing , Vivien Didelot , Andrew Lunn , "David S. Miller" Subject: [PATCH 5.0 110/137] net: dsa: Fix error cleanup path in dsa_init_module Date: Wed, 15 May 2019 12:56:31 +0200 Message-Id: <20190515090701.573497652@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190515090651.633556783@linuxfoundation.org> References: <20190515090651.633556783@linuxfoundation.org> User-Agent: quilt/0.66 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 From: YueHaibing [ Upstream commit 68be930249d051fd54d3d99156b3dcadcb2a1f9b ] BUG: unable to handle kernel paging request at ffffffffa01c5430 PGD 3270067 P4D 3270067 PUD 3271063 PMD 230bc5067 PTE 0 Oops: 0000 [#1 CPU: 0 PID: 6159 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:raw_notifier_chain_register+0x16/0x40 Code: 63 f8 66 90 e9 5d ff ff ff 90 90 90 90 90 90 90 90 90 90 90 55 48 8b 07 48 89 e5 48 85 c0 74 1c 8b 56 10 3b 50 10 7e 07 eb 12 <39> 50 10 7c 0d 48 8d 78 08 48 8b 40 08 48 85 c0 75 ee 48 89 46 08 RSP: 0018:ffffc90001c33c08 EFLAGS: 00010282 RAX: ffffffffa01c5420 RBX: ffffffffa01db420 RCX: 4fcef45928070a8b RDX: 0000000000000000 RSI: ffffffffa01db420 RDI: ffffffffa01b0068 RBP: ffffc90001c33c08 R08: 000000003e0a33d0 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000094443661 R12: ffff88822c320700 R13: ffff88823109be80 R14: 0000000000000000 R15: ffffc90001c33e78 FS: 00007fab8bd08540(0000) GS:ffff888237a00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffffffa01c5430 CR3: 00000002297ea000 CR4: 00000000000006f0 Call Trace: register_netdevice_notifier+0x43/0x250 ? 0xffffffffa01e0000 dsa_slave_register_notifier+0x13/0x70 [dsa_core ? 0xffffffffa01e0000 dsa_init_module+0x2e/0x1000 [dsa_core 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 Cleanup allocated resourses if there are errors, otherwise it will trgger memleak. Fixes: c9eb3e0f8701 ("net: dsa: Add support for learning FDB through notification") Signed-off-by: YueHaibing Reviewed-by: Vivien Didelot Reviewed-by: Andrew Lunn Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/dsa/dsa.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c @@ -342,15 +342,22 @@ static int __init dsa_init_module(void) rc = dsa_slave_register_notifier(); if (rc) - return rc; + goto register_notifier_fail; rc = dsa_legacy_register(); if (rc) - return rc; + goto legacy_register_fail; dev_add_pack(&dsa_pack_type); return 0; + +legacy_register_fail: + dsa_slave_unregister_notifier(); +register_notifier_fail: + destroy_workqueue(dsa_owq); + + return rc; } module_init(dsa_init_module);