[PATCH 1/8] usb: gadget: dummy_hcd: replace BUG() with WARN_ON_ONCE()
From: Clint George
Date: Wed Nov 19 2025 - 08:08:55 EST
Replace BUG() with WARN_ON_ONCE() in dummy_validate_stream()
when stream_id exceeds max_streams. This allows the kernel to
continue running with a warning instead of crashing.
Signed-off-by: Clint George <clintbgeorge@xxxxxxxxx>
---
Testing:
- The function dummy_validate_stream() was tested using a test module
that i created where i sent value of urb->stream_id greater than
max_streams. When using BUG(), the kernel-space used to crash but
after using WARN_ON_ONCE() the kernel-space does not crash and the
module terminates gracefully
- Ensured that the module builds properly
drivers/usb/gadget/udc/dummy_hcd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
index 1cefca660..41b7b6907 100644
--- a/drivers/usb/gadget/udc/dummy_hcd.c
+++ b/drivers/usb/gadget/udc/dummy_hcd.c
@@ -1254,7 +1254,7 @@ static int dummy_validate_stream(struct dummy_hcd *dum_hcd, struct urb *urb)
if (urb->stream_id > max_streams) {
dev_err(dummy_dev(dum_hcd), "Stream id %d is out of range.\n",
urb->stream_id);
- BUG();
+ WARN_ON_ONCE(1);
return -EINVAL;
}
return 0;
--
2.43.0