aboutsummaryrefslogtreecommitdiff
path: root/embassy-usb-synopsys-otg/src
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2024-08-03 00:14:11 +0200
committerDario Nieuwenhuis <[email protected]>2024-08-03 00:15:45 +0200
commit7d65c5c4fa9f4a931019625168d7eacf0ec2fa40 (patch)
tree7a2c9b6187c779efd1c3f04400becae59fc23850 /embassy-usb-synopsys-otg/src
parenta2ea2630f648a9a46dc4f9276d9f5eaf256ae893 (diff)
usb-synopsys-otg: ensure ep alloc fails when endpoint_count < MAX_EP_COUNT.
Before, it would alloc the endpoint fine and then panic later due to out of range. This ensures it falis at ep alloc time, and with a panic message that says what's the actual problem: "no free endpoints available".
Diffstat (limited to 'embassy-usb-synopsys-otg/src')
-rw-r--r--embassy-usb-synopsys-otg/src/lib.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/embassy-usb-synopsys-otg/src/lib.rs b/embassy-usb-synopsys-otg/src/lib.rs
index b90e059f6..f155f1522 100644
--- a/embassy-usb-synopsys-otg/src/lib.rs
+++ b/embassy-usb-synopsys-otg/src/lib.rs
@@ -382,8 +382,8 @@ impl<'d, const MAX_EP_COUNT: usize> Driver<'d, MAX_EP_COUNT> {
382 } 382 }
383 383
384 let eps = match D::dir() { 384 let eps = match D::dir() {
385 Direction::Out => &mut self.ep_out, 385 Direction::Out => &mut self.ep_out[..self.instance.endpoint_count],
386 Direction::In => &mut self.ep_in, 386 Direction::In => &mut self.ep_in[..self.instance.endpoint_count],
387 }; 387 };
388 388
389 // Find free endpoint slot 389 // Find free endpoint slot