Skip to content

Commit 61684c0

Browse files
Gil Finewesteri
authored andcommitted
thunderbolt: Fix uninitialized variable in tb_tunnel_alloc_usb3()
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: 25d905d ("thunderbolt: Allow USB3 bandwidth to be lower than maximum supported") Signed-off-by: Gil Fine <[email protected]> Signed-off-by: Mika Westerberg <[email protected]>
1 parent a3ad3a9 commit 61684c0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/thunderbolt/tunnel.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2048,10 +2048,10 @@ struct tb_tunnel *tb_tunnel_discover_usb3(struct tb *tb, struct tb_port *down,
20482048
* @tb: Pointer to the domain structure
20492049
* @up: USB3 upstream adapter port
20502050
* @down: USB3 downstream adapter port
2051-
* @max_up: Maximum available upstream bandwidth for the USB3 tunnel (%0
2052-
* if not limited).
2053-
* @max_down: Maximum available downstream bandwidth for the USB3 tunnel
2054-
* (%0 if not limited).
2051+
* @max_up: Maximum available upstream bandwidth for the USB3 tunnel.
2052+
* %0 if no available bandwidth.
2053+
* @max_down: Maximum available downstream bandwidth for the USB3 tunnel.
2054+
* %0 if no available bandwidth.
20552055
*
20562056
* Allocate an USB3 tunnel. The ports must be of type @TB_TYPE_USB3_UP and
20572057
* @TB_TYPE_USB3_DOWN.
@@ -2064,7 +2064,7 @@ struct tb_tunnel *tb_tunnel_alloc_usb3(struct tb *tb, struct tb_port *up,
20642064
{
20652065
struct tb_tunnel *tunnel;
20662066
struct tb_path *path;
2067-
int max_rate;
2067+
int max_rate = 0;
20682068

20692069
if (!tb_route(down->sw) && (max_up > 0 || max_down > 0)) {
20702070
/*

0 commit comments

Comments
 (0)