mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] greybus: svc_watchdog: initialize reset_work only once
@ 2026-11-27  7:52 Jiayi Zhang
  2026-11-27  8:01 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 2+ messages in thread
From: Jiayi Zhang @ 2026-11-27  7:52 UTC (permalink / raw)
  To: Johan Hovold, Alex Elder, Greg Kroah-Hartman
  Cc: Rui Miguel Silva, Farhad Alemi, greybus-dev, linux-kernel,
	syzbot+e6bea924b5ee24f7cb98, syzkaller-bugs, Jiayi Zhang

reset_work is a file-scope delayed work shared by all SVC watchdogs, but
do_work() calls INIT_DELAYED_WORK() on it every time a ping fails, right
before scheduling it to run half a second later. With two host devices,
the watchdog of the second SVC can see its ping fail while the work
scheduled by the first one is still pending. INIT_DELAYED_WORK() then
reinitializes a timer that is still enqueued, and debugobjects reports:

  greybus 1-svc: Resetting the greybus network, watch out!!!
  greybus 2-svc: Resetting the greybus network, watch out!!!
  ODEBUG: init active (active state 0) object: ffffffff9bda1f68 object type: timer_list hint: greybus_reset+0x0/0x50
  WARNING: lib/debugobjects.c:629 at debug_print_object+0x198/0x2b0
  Workqueue: events do_work
  Call Trace:
   __debug_object_init
   timer_init_key
   do_work drivers/greybus/svc_watchdog.c:92
   process_one_work

Without CONFIG_DEBUG_OBJECTS_TIMERS nothing catches this and the timer
is added to the timer wheel a second time while it is still linked there.

Initialize reset_work once with DECLARE_DELAYED_WORK() and only schedule
it from do_work(). schedule_delayed_work() does nothing when the work is
already pending, which is what is wanted here: greybus_reset() resets the
whole greybus network, so one run serves both watchdogs.

Fixes: ed7279ae31b0 ("greybus: svc: add a "watchdog" to check the network health")
Reported-by: syzbot+e6bea924b5ee24f7cb98@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=e6bea924b5ee24f7cb98
Link: https://lore.kernel.org/r/CA+0ovCiyBFo_gx4UaRN095=MdWaBgKm=TqA1uYdOu-hb_BPt6A@mail.gmail.com/
Signed-off-by: Jiayi Zhang <zhangjiayi1014@gmail.com>
---
Compile tested only (allmodconfig, W=1); syzbot has no reproducer for
this report.

AI tools assisted with the analysis, the code and the changelog.

 drivers/greybus/svc_watchdog.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/greybus/svc_watchdog.c b/drivers/greybus/svc_watchdog.c
index b318eb34bcca..11eb7c961b06 100644
--- a/drivers/greybus/svc_watchdog.c
+++ b/drivers/greybus/svc_watchdog.c
@@ -20,8 +20,6 @@ struct gb_svc_watchdog {
 	struct notifier_block pm_notifier;
 };
 
-static struct delayed_work reset_work;
-
 static int svc_watchdog_pm_notifier(struct notifier_block *notifier,
 				    unsigned long pm_event, void *unused)
 {
@@ -61,6 +59,8 @@ static void greybus_reset(struct work_struct *work)
 	call_usermodehelper(start_path, argv, envp, UMH_WAIT_EXEC);
 }
 
+static DECLARE_DELAYED_WORK(reset_work, greybus_reset);
+
 static void do_work(struct work_struct *work)
 {
 	struct gb_svc_watchdog *watchdog;
@@ -89,7 +89,6 @@ static void do_work(struct work_struct *work)
 		} else if (svc->action == GB_SVC_WATCHDOG_BITE_RESET_UNIPRO) {
 			dev_err(&svc->dev, "Resetting the greybus network, watch out!!!\n");
 
-			INIT_DELAYED_WORK(&reset_work, greybus_reset);
 			schedule_delayed_work(&reset_work, HZ / 2);
 
 			/*

base-commit: 9437ee8b6cf607e883b36e44bd755968daaebd48
-- 
2.53.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] greybus: svc_watchdog: initialize reset_work only once
  2026-11-27  7:52 [PATCH] greybus: svc_watchdog: initialize reset_work only once Jiayi Zhang
@ 2026-11-27  8:01 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2026-11-27  8:01 UTC (permalink / raw)
  To: Jiayi Zhang
  Cc: Johan Hovold, Alex Elder, Rui Miguel Silva, Farhad Alemi,
	greybus-dev, linux-kernel, syzbot+e6bea924b5ee24f7cb98,
	syzkaller-bugs

On Fri, Nov 27, 2026 at 07:52:43AM +0000, Jiayi Zhang wrote:
> reset_work is a file-scope delayed work shared by all SVC watchdogs, but
> do_work() calls INIT_DELAYED_WORK() on it every time a ping fails, right
> before scheduling it to run half a second later. With two host devices,
> the watchdog of the second SVC can see its ping fail while the work
> scheduled by the first one is still pending. INIT_DELAYED_WORK() then
> reinitializes a timer that is still enqueued, and debugobjects reports:
> 
>   greybus 1-svc: Resetting the greybus network, watch out!!!
>   greybus 2-svc: Resetting the greybus network, watch out!!!
>   ODEBUG: init active (active state 0) object: ffffffff9bda1f68 object type: timer_list hint: greybus_reset+0x0/0x50
>   WARNING: lib/debugobjects.c:629 at debug_print_object+0x198/0x2b0
>   Workqueue: events do_work
>   Call Trace:
>    __debug_object_init
>    timer_init_key
>    do_work drivers/greybus/svc_watchdog.c:92
>    process_one_work

Cool, how are you running this?  What fake devices do you have where you
have two svc hosts?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-27  8:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-27  7:52 [PATCH] greybus: svc_watchdog: initialize reset_work only once Jiayi Zhang
2026-11-27  8:01 ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®