From c76cbf348c7df077f93fa99a1225a527ce64cfa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 3 Aug 2026 05:08:02 +0200 Subject: [PATCH] xen/xenbus: check otherend_id only after it has been initialized MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When device just got initialized (for example on module load), the otherend_id field is initialized only after xenbus_read_otherend_details() gets called. If xenstore watch triggers xenbus_dev_changed() before that, it might consider still zeroed otherend_id field (not matching actual xenstore content) as a sign of device state reset. It can happen because xenstore watch are handled in another thread (xenwatch), which can run in parallel to the initial device probe running at module load. In that case, it would call device_unregister(), which would deadlock against device probe from module init. Fix this by considering dev->otherend_id change only after dev->otherend is set (which happen after otherend_id is initialized). Fixes: e2dcf9065536 "xen/xenbus: better handle backend crash" Signed-off-by: Marek Marczykowski-Górecki Reviewed-by: Juergen Gross Signed-off-by: Juergen Gross Message-ID: <20260803030822.4104093-2-marmarek@invisiblethingslab.com> --- drivers/xen/xenbus/xenbus_probe.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c index 111849756e0c..59d106818536 100644 --- a/drivers/xen/xenbus/xenbus_probe.c +++ b/drivers/xen/xenbus/xenbus_probe.c @@ -681,7 +681,8 @@ void xenbus_dev_changed(const char *node, struct xen_bus_type *bus) dev->otherend_id); if (state == XenbusStateInitialising && - (state != dev->state || backend != dev->otherend_id)) { + (state != dev->state || + (dev->otherend && backend != dev->otherend_id))) { /* * State has been reset, assume the old one vanished * and new one needs to be probed.