[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211115222719.2558207-1-sstabellini@kernel.org>
Date: Mon, 15 Nov 2021 14:27:19 -0800
From: Stefano Stabellini <sstabellini@...nel.org>
To: jgross@...e.com
Cc: boris.ostrovsky@...cle.com, xen-devel@...ts.xenproject.org,
linux-kernel@...r.kernel.org, sstabellini@...nel.org,
Stefano Stabellini <stefano.stabellini@...inx.com>,
Stable@...r.kernel.org, jbeulich@...e.com
Subject: [PATCH v2] xen: don't continue xenstore initialization in case of errors
From: Stefano Stabellini <stefano.stabellini@...inx.com>
In case of errors in xenbus_init (e.g. missing xen_store_gfn parameter),
we goto out_error but we forget to reset xen_store_domain_type to
XS_UNKNOWN. As a consequence xenbus_probe_initcall and other initcalls
will still try to initialize xenstore resulting into a crash at boot.
[ 2.479830] Call trace:
[ 2.482314] xb_init_comms+0x18/0x150
[ 2.486354] xs_init+0x34/0x138
[ 2.489786] xenbus_probe+0x4c/0x70
[ 2.498432] xenbus_probe_initcall+0x2c/0x7c
[ 2.503944] do_one_initcall+0x54/0x1b8
[ 2.507358] kernel_init_freeable+0x1ac/0x210
[ 2.511617] kernel_init+0x28/0x130
[ 2.516112] ret_from_fork+0x10/0x20
Cc: <Stable@...r.kernel.org>
Cc: jbeulich@...e.com
Signed-off-by: Stefano Stabellini <stefano.stabellini@...inx.com>
---
Changes in v2:
- use return 0 for the success case
- remove err initializer as it is not useful any longer
---
drivers/xen/xenbus/xenbus_probe.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c
index bd003ca8acbe..5967aa937255 100644
--- a/drivers/xen/xenbus/xenbus_probe.c
+++ b/drivers/xen/xenbus/xenbus_probe.c
@@ -909,7 +909,7 @@ static struct notifier_block xenbus_resume_nb = {
static int __init xenbus_init(void)
{
- int err = 0;
+ int err;
uint64_t v = 0;
xen_store_domain_type = XS_UNKNOWN;
@@ -983,8 +983,10 @@ static int __init xenbus_init(void)
*/
proc_create_mount_point("xen");
#endif
+ return 0;
out_error:
+ xen_store_domain_type = XS_UNKNOWN;
return err;
}
--
2.25.1
Powered by blists - more mailing lists