]> Git Repo - J-linux.git/commitdiff
thunderbolt: Fix uninitialized variable in tb_tunnel_alloc_usb3()
authorGil Fine <[email protected]>
Thu, 25 Apr 2024 23:24:17 +0000 (02:24 +0300)
committerMika Westerberg <[email protected]>
Sat, 27 Apr 2024 05:02:01 +0000 (08:02 +0300)
Currently in case of no bandwidth available for USB3 tunnel, we are left
with uninitialized variable that can lead to huge negative allocated
bandwidth.

Fix this by initializing the variable to zero. While there, fix the
kernel-doc to describe more accurately the purpose of the function
tb_tunnel_alloc_usb3().

Reported-by: Dan Carpenter <[email protected]>
Closes: https://lore.kernel.org/linux-usb/[email protected]/
Fixes: 25d905d2b819 ("thunderbolt: Allow USB3 bandwidth to be lower than maximum supported")
Signed-off-by: Gil Fine <[email protected]>
Signed-off-by: Mika Westerberg <[email protected]>
drivers/thunderbolt/tunnel.c

index fdc5e8e12ca8ec48ade006ee76dd8979ca12df29..1a3b197001dafa5dab0f34a71ed3cee107a2b4d1 100644 (file)
@@ -2048,10 +2048,10 @@ err_free:
  * @tb: Pointer to the domain structure
  * @up: USB3 upstream adapter port
  * @down: USB3 downstream adapter port
- * @max_up: Maximum available upstream bandwidth for the USB3 tunnel (%0
- *         if not limited).
- * @max_down: Maximum available downstream bandwidth for the USB3 tunnel
- *           (%0 if not limited).
+ * @max_up: Maximum available upstream bandwidth for the USB3 tunnel.
+ *         %0 if no available bandwidth.
+ * @max_down: Maximum available downstream bandwidth for the USB3 tunnel.
+ *           %0 if no available bandwidth.
  *
  * Allocate an USB3 tunnel. The ports must be of type @TB_TYPE_USB3_UP and
  * @TB_TYPE_USB3_DOWN.
@@ -2064,7 +2064,7 @@ struct tb_tunnel *tb_tunnel_alloc_usb3(struct tb *tb, struct tb_port *up,
 {
        struct tb_tunnel *tunnel;
        struct tb_path *path;
-       int max_rate;
+       int max_rate = 0;
 
        if (!tb_route(down->sw) && (max_up > 0 || max_down > 0)) {
                /*
This page took 0.050765 seconds and 4 git commands to generate.