Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1148140ybi; Fri, 2 Aug 2019 10:05:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqwACS47+dMhGaFG5r8SsylPY20b31ZgRdXUwwBZ77mF6IXIFzehqZY412bZQxO8wXtEGlIF X-Received: by 2002:a17:902:6a88:: with SMTP id n8mr132430462plk.70.1564765507887; Fri, 02 Aug 2019 10:05:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564765507; cv=none; d=google.com; s=arc-20160816; b=KNkZvCQwZDOYd7ec82xMqxOzMlMDTgVfcsGC9qxmXxExZ4rgMSHZ0tVgR5SsZdMkKq 7Nj3Pm8zIlmqCdqwgS6/III9sEhlvdcfNH2FpBNludx7vKSWS4AxAYT0PZXg9ROcx0pA q1+8JF2u9P6mSfUV9tcmQwmbEcNfvDF4KrBfjGvc2j7GkTdDqbZvSBCRrw0gQbddLuro 6PIl2Mk8t8VE/uWSofPUMROhjsBujTq4s1dp92XMd9QzzghrnUgQIGS0Oev7dmzvthaM GLxo+SPnT1tPAuRVvUXDPoMsvncdxwLcHRl9SVjnsyzyMDISiRcoC8ouBJZdddze+8Dp niRA== 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=eWOb3nG36bIS26VlOaLcYB4SV6Uwj3vC/CYmlnx1n3U=; b=BLMljtzgCbGL/C2MGIgru/ngV5raDZOqUL3wV/0v88DG4COLXqt7/eHPO0NMuBBWXF ed0hHJBsFbN6UlRo3PIR18k052y47FokbNDiITinzNG117bDTLSKtx8RqP1q2fvfNKGw mVYp7Whck3ZpEZPVhDtmeK22gVUYhwioHbRaZy38oIQW5gn2ULYZBEmnz7AEwRjecpqv yPrYlhxDy+OY7hQnGfWVI+HyckC4qFO85vovLQB0ig7/6TPGGvQp2AJ2su43hlIsLzs+ d6tQh8rkNq4Fpz8VNhc3FbI1EF70U1NEf2N9Yzi2GBH/fLFwG/HXTmjpTMrLAaSBlNif 1Nbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gw8RwFbB; 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 q15si3982786pls.184.2019.08.02.10.04.52; Fri, 02 Aug 2019 10:05:07 -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=gw8RwFbB; 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 S2405357AbfHBJpE (ORCPT + 99 others); Fri, 2 Aug 2019 05:45:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:48600 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729459AbfHBJpC (ORCPT ); Fri, 2 Aug 2019 05:45:02 -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 6915820B7C; Fri, 2 Aug 2019 09:45:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564739100; bh=IfKP9fPXVIDENSW5kVJ6Tbtk+1Ef//4tUYQRwZmXtss=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gw8RwFbBsknM+JIhoE8iJb7tDBw40Be6j0TPcvBpJfnYlgoRlS6Pw82pc8gwTv3dP RQ/BIQrpW259iDANxjlK6UudYa71sTQiIxFThyz1y/AwHSbiroBINzhUAM+0IdyK3N bkT5XDQG6eq/h3Dg7LxIvx4rDB3OscUITJ//ZJ9Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , YueHaibing , Dominique Martinet Subject: [PATCH 4.9 099/223] 9p/virtio: Add cleanup path in p9_virtio_init Date: Fri, 2 Aug 2019 11:35:24 +0200 Message-Id: <20190802092245.590360320@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802092238.692035242@linuxfoundation.org> References: <20190802092238.692035242@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 commit d4548543fc4ece56c6f04b8586f435fb4fd84c20 upstream. KASAN report this: BUG: unable to handle kernel paging request at ffffffffa0097000 PGD 3870067 P4D 3870067 PUD 3871063 PMD 2326e2067 PTE 0 Oops: 0000 [#1 CPU: 0 PID: 5340 Comm: modprobe Not tainted 5.1.0-rc7+ #25 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.9.3-0-ge2fc41e-prebuilt.qemu-project.org 04/01/2014 RIP: 0010:__list_add_valid+0x10/0x70 Code: c3 48 8b 06 55 48 89 e5 5d 48 39 07 0f 94 c0 0f b6 c0 c3 90 90 90 90 90 90 90 55 48 89 d0 48 8b 52 08 48 89 e5 48 39 f2 75 19 <48> 8b 32 48 39 f0 75 3a RSP: 0018:ffffc90000e23c68 EFLAGS: 00010246 RAX: ffffffffa00ad000 RBX: ffffffffa009d000 RCX: 0000000000000000 RDX: ffffffffa0097000 RSI: ffffffffa0097000 RDI: ffffffffa009d000 RBP: ffffc90000e23c68 R08: 0000000000000001 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: ffffffffa0097000 R13: ffff888231797180 R14: 0000000000000000 R15: ffffc90000e23e78 FS: 00007fb215285540(0000) GS:ffff888237a00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffffffa0097000 CR3: 000000022f144000 CR4: 00000000000006f0 Call Trace: v9fs_register_trans+0x2f/0x60 [9pnet ? 0xffffffffa0087000 p9_virtio_init+0x25/0x1000 [9pnet_virtio do_one_initcall+0x6c/0x3cc ? kmem_cache_alloc_trace+0x248/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 RIP: 0033:0x7fb214d8e839 Code: 00 f3 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 RSP: 002b:00007ffc96554278 EFLAGS: 00000246 ORIG_RAX: 0000000000000139 RAX: ffffffffffffffda RBX: 000055e67eed2aa0 RCX: 00007fb214d8e839 RDX: 0000000000000000 RSI: 000055e67ce95c2e RDI: 0000000000000003 RBP: 000055e67ce95c2e R08: 0000000000000000 R09: 000055e67eed2aa0 R10: 0000000000000003 R11: 0000000000000246 R12: 0000000000000000 R13: 000055e67eeda500 R14: 0000000000040000 R15: 000055e67eed2aa0 Modules linked in: 9pnet_virtio(+) 9pnet gre rfkill vmw_vsock_virtio_transport_common vsock [last unloaded: 9pnet_virtio CR2: ffffffffa0097000 ---[ end trace 4a52bb13ff07b761 If register_virtio_driver() fails in p9_virtio_init, we should call v9fs_unregister_trans() to do cleanup. Link: http://lkml.kernel.org/r/20190430115942.41840-1-yuehaibing@huawei.com Cc: stable@vger.kernel.org Reported-by: Hulk Robot Fixes: b530cc794024 ("9p: add virtio transport") Signed-off-by: YueHaibing Signed-off-by: Dominique Martinet Signed-off-by: Greg Kroah-Hartman --- net/9p/trans_virtio.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/net/9p/trans_virtio.c +++ b/net/9p/trans_virtio.c @@ -764,10 +764,16 @@ static struct p9_trans_module p9_virtio_ /* The standard init function */ static int __init p9_virtio_init(void) { + int rc; + INIT_LIST_HEAD(&virtio_chan_list); v9fs_register_trans(&p9_virtio_trans); - return register_virtio_driver(&p9_virtio_drv); + rc = register_virtio_driver(&p9_virtio_drv); + if (rc) + v9fs_unregister_trans(&p9_virtio_trans); + + return rc; } static void __exit p9_virtio_cleanup(void)