Skip to content

Commit 7f5d62f

Browse files
committed
zephyr: device: uart: irq: panic on drop
Because this interface has registered IRQs, prevent drops. They are probably safe due to the use of the leaked Arc, but the data is in fact leaked. For now, just cause Drop to panic, as normal use won't ever drop this. Signed-off-by: David Brown <[email protected]>
1 parent a114c77 commit 7f5d62f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

zephyr/src/device/uart/irq.rs

+9
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,15 @@ impl<const WS: usize, const RS: usize> UartIrq<WS, RS> {
220220
}
221221
}
222222

223+
// TODO: It could actually be possible to implement drop, but we would need to make sure the irq
224+
// handlers are deregistered. These is also the issue of the buffers being dropped. For now, just
225+
// panic, as this isn't normal.
226+
impl<const WS: usize, const RS: usize> Drop for UartIrq<WS, RS> {
227+
fn drop(&mut self) {
228+
panic!("UartIrq dropped");
229+
}
230+
}
231+
223232
impl<const WS: usize, const RS: usize> IrqOuterData<WS, RS> {
224233
/// Try reading from the inner data, filling the buffer with as much data as makes sense.
225234
/// Returns the number of bytes actually read, or Zero if none.

0 commit comments

Comments
 (0)