Skip to contentSkip to conversation

rpmsg: virtio: fix error handling in TX buffer wait

PATCH Applied Atul Akella 2 participants 2 messages Oct 13 – Oct 14 Remote processor messaging (rpmsg)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rpmsg: virtio: fix error handling in TX buffer wait

The TX buffer wait loop in rpmsg_send_offchannel_raw() ignores the possibility of wait_event_interruptible_timeout() returning a negative value, which happens when the wait is interrupted by a signal. In that case the loop spins back around and re-arms the wait instead of propagating the signal, which can stall a task that is trying to be killed.

Separately, on a genuine timeout (return value 0) the function returns -ERESTARTSYS, which is reserved for signal-interrupted syscalls that the kernel may restart. A timeout is not a signal and should not be treated as restartable; return -ETIMEDOUT instead.

Handle both cases explicitly: return err directly when negative, and return -ETIMEDOUT on timeout.

Fixes bcabbccabffe ("rpmsg: add virtio-based remote processor messaging bus")
---
 drivers/rpmsg/virtio_rpmsg_bus.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/rpmsg/virtio_rpmsg_bus.c +4 -1
index 1b8bb05924af..a32772d6ccbc 100644
@@ -536,10 +536,13 @@ static int rpmsg_send_offchannel_raw(struct rpmsg_device *rpdev,
 					(msg = get_a_tx_buf(vrp)),
 					msecs_to_jiffies(15000));
 
+		if (err < 0)
+			return err;
+
 		/* timeout ? */
 		if (!err) {
 			dev_err(dev, "timeout waiting for a tx buffer\n");
-			return -ERESTARTSYS;
+			return -ETIMEDOUT;
 		}
 	}
 
Signature · 1 line
2.51.0.windows.1
maintainer Applied
#1 lore raw
Quoted 28 lines · Atul Akella

The TX buffer wait loop in rpmsg_send_offchannel_raw() ignores the possibility of wait_event_interruptible_timeout() returning a negative value, which happens when the wait is interrupted by a signal. In that case the loop spins back around and re-arms the wait instead of propagating the signal, which can stall a task that is trying to be killed.

Separately, on a genuine timeout (return value 0) the function returns -ERESTARTSYS, which is reserved for signal-interrupted syscalls that the kernel may restart. A timeout is not a signal and should not be treated as restartable; return -ETIMEDOUT instead.

Handle both cases explicitly: return err directly when negative, and return -ETIMEDOUT on timeout.

Fixes bcabbccabffe ("rpmsg: add virtio-based remote processor messaging bus")
---
 drivers/rpmsg/virtio_rpmsg_bus.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/rpmsg/virtio_rpmsg_bus.c +0 -0
index 1b8bb05924af..a32772d6ccbc 100644
@@ -536,10 +536,13 @@ static int rpmsg_send_offchannel_raw(struct rpmsg_device *rpdev,
 					(msg = get_a_tx_buf(vrp)),

drivers/rpmsg/virtio_rpmsg_bus.c static int rpmsg_send_offchannel_raw(struct rpmsg_device *rpdev, · line 545

Quoted 10 lines
drivers/rpmsg/virtio_rpmsg_bus.c +4 -1
 					msecs_to_jiffies(15000));
 
+		if (err < 0)
+			return err;
+
 		/* timeout ? */
 		if (!err) {
 			dev_err(dev, "timeout waiting for a tx buffer\n");
-			return -ERESTARTSYS;
+			return -ETIMEDOUT;

Applied.

Thanks,
Mathieu

Quoted 6 lines
drivers/rpmsg/virtio_rpmsg_bus.c +0 -0
 		}
 	}
 
Signature · 1 line
2.51.0.windows.1