Skip to contentSkip to conversation

usb: serial: digi_accelport: fix crash on SPARC

PATCH In review Oliver Neukum 2 participants 2 messages Aug 4

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: serial: digi_accelport: fix crash on SPARC

The helper function cond_wait_interruptible_timeout_irqrestore() reenables interrupts. It does so by means of the flags saved by spin_lock_irqsave() in the caller.
On SPARC these flags can be used only inside the same stack frame. Details can be found in

https://www.kernel.org/pub/linux/kernel/people/rusty/kernel-locking/x467.html

If the compiler decides to not inline the helper function, the kernel will crash on SPARC if the helper is executed. Hence the compiler needs to be forced to always inline the function. The bug was inadvertedly introduced by an adaption to modern coding standards.

Fixes c6d61269f530e ("digi_acceleport: Drag the driver kicking and screaming into coding style")
---
 drivers/usb/serial/digi_acceleport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/serial/digi_acceleport.c +1 -1
index a687217eadd7..50b89316ba1c 100644
@@ -336,7 +336,7 @@ static struct usb_serial_driver * const serial_drivers[] = {
  *  with the equivalent code.
  */
 
-static long cond_wait_interruptible_timeout_irqrestore(
+static __always_inline long cond_wait_interruptible_timeout_irqrestore(
 	wait_queue_head_t *q, long timeout,
 	spinlock_t *lock, unsigned long flags)
 __releases(lock)
Signature · 1 line
2.55.0
maintainer
#1 lore raw
Quoted 10 lines · Oliver Neukum

The helper function cond_wait_interruptible_timeout_irqrestore() reenables interrupts. It does so by means of the flags saved by spin_lock_irqsave() in the caller.
On SPARC these flags can be used only inside the same stack frame. Details can be found in

https://www.kernel.org/pub/linux/kernel/people/rusty/kernel-locking/x467.html

If the compiler decides to not inline the helper function, the kernel will crash on SPARC if the helper is executed.

I too had seen that comment about the messed up SPARC, but some years back I looked into it and concluded that this hasn't been the case for a very long time.

Specifically, the comment you refer to was removed from the in-tree version of that document in 2004 after SPARC was fixed.

Johan