thunderbolt: Check for ring 0 in tb_tunnel_alloc_dma()
authorMika Westerberg <mika.westerberg@linux.intel.com>
Fri, 31 Mar 2023 10:01:32 +0000 (13:01 +0300)
committerMika Westerberg <mika.westerberg@linux.intel.com>
Wed, 24 May 2023 06:39:34 +0000 (09:39 +0300)
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

index 9099ae73e78f39417e3d67b1706722f610450f6e..dd3b5613ad2c60112605a6ea673f6479f0ecb0d5 100644 (file)
@@ -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)