diff mbox series

[1/7] thunderbolt: Check for ring 0 in tb_tunnel_alloc_dma()

Message ID 20230517084103.45213-1-mika.westerberg@linux.intel.com (mailing list archive)
State Accepted
Commit 814c96c959cfc147ecf8bf9ae3f34b8361316316
Headers show
Series [1/7] thunderbolt: Check for ring 0 in tb_tunnel_alloc_dma() | expand

Commit Message

Mika Westerberg May 17, 2023, 8:40 a.m. UTC
Ring 0 cannot be used for anything else than control channel messages.
For this reason add a check to tb_tunnel_alloc_dma() and fail if someone
tries to do that.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/tunnel.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Mika Westerberg May 24, 2023, 6:42 a.m. UTC | #1
On Wed, May 17, 2023 at 11:40:57AM +0300, Mika Westerberg wrote:
> Ring 0 cannot be used for anything else than control channel messages.
> For this reason add a check to tb_tunnel_alloc_dma() and fail if someone
> tries to do that.
> 
> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>

All applied to thunderbolt.git/next.
diff mbox series

Patch

diff --git a/drivers/thunderbolt/tunnel.c b/drivers/thunderbolt/tunnel.c
index 9099ae73e78f..dd3b5613ad2c 100644
--- a/drivers/thunderbolt/tunnel.c
+++ b/drivers/thunderbolt/tunnel.c
@@ -1452,6 +1452,10 @@  struct tb_tunnel *tb_tunnel_alloc_dma(struct tb *tb, struct tb_port *nhi,
 	struct tb_path *path;
 	int credits;
 
+	/* Ring 0 is reserved for control channel */
+	if (WARN_ON(!receive_ring || !transmit_ring))
+		return NULL;
+
 	if (receive_ring > 0)
 		npaths++;
 	if (transmit_ring > 0)