Commit ec4405ed authored by Gil Fine's avatar Gil Fine Committed by Mika Westerberg

thunderbolt: Call tb_switch_put() once DisplayPort bandwidth request is finished

When handling DisplayPort bandwidth request tb_switch_find_by_route() is
called and it returns a router structure with reference count increased.
In order to avoid resource leak call tb_switch_put() when finished.

Fixes: 6ce35635 ("thunderbolt: Add support for DisplayPort bandwidth allocation mode")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarGil Fine <gil.fine@linux.intel.com>
Signed-off-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
parent 8a749fd1
...@@ -1907,14 +1907,14 @@ static void tb_handle_dp_bandwidth_request(struct work_struct *work) ...@@ -1907,14 +1907,14 @@ static void tb_handle_dp_bandwidth_request(struct work_struct *work)
in = &sw->ports[ev->port]; in = &sw->ports[ev->port];
if (!tb_port_is_dpin(in)) { if (!tb_port_is_dpin(in)) {
tb_port_warn(in, "bandwidth request to non-DP IN adapter\n"); tb_port_warn(in, "bandwidth request to non-DP IN adapter\n");
goto unlock; goto put_sw;
} }
tb_port_dbg(in, "handling bandwidth allocation request\n"); tb_port_dbg(in, "handling bandwidth allocation request\n");
if (!usb4_dp_port_bandwidth_mode_enabled(in)) { if (!usb4_dp_port_bandwidth_mode_enabled(in)) {
tb_port_warn(in, "bandwidth allocation mode not enabled\n"); tb_port_warn(in, "bandwidth allocation mode not enabled\n");
goto unlock; goto put_sw;
} }
ret = usb4_dp_port_requested_bandwidth(in); ret = usb4_dp_port_requested_bandwidth(in);
...@@ -1923,7 +1923,7 @@ static void tb_handle_dp_bandwidth_request(struct work_struct *work) ...@@ -1923,7 +1923,7 @@ static void tb_handle_dp_bandwidth_request(struct work_struct *work)
tb_port_dbg(in, "no bandwidth request active\n"); tb_port_dbg(in, "no bandwidth request active\n");
else else
tb_port_warn(in, "failed to read requested bandwidth\n"); tb_port_warn(in, "failed to read requested bandwidth\n");
goto unlock; goto put_sw;
} }
requested_bw = ret; requested_bw = ret;
...@@ -1932,7 +1932,7 @@ static void tb_handle_dp_bandwidth_request(struct work_struct *work) ...@@ -1932,7 +1932,7 @@ static void tb_handle_dp_bandwidth_request(struct work_struct *work)
tunnel = tb_find_tunnel(tb, TB_TUNNEL_DP, in, NULL); tunnel = tb_find_tunnel(tb, TB_TUNNEL_DP, in, NULL);
if (!tunnel) { if (!tunnel) {
tb_port_warn(in, "failed to find tunnel\n"); tb_port_warn(in, "failed to find tunnel\n");
goto unlock; goto put_sw;
} }
out = tunnel->dst_port; out = tunnel->dst_port;
...@@ -1959,6 +1959,8 @@ static void tb_handle_dp_bandwidth_request(struct work_struct *work) ...@@ -1959,6 +1959,8 @@ static void tb_handle_dp_bandwidth_request(struct work_struct *work)
tb_recalc_estimated_bandwidth(tb); tb_recalc_estimated_bandwidth(tb);
} }
put_sw:
tb_switch_put(sw);
unlock: unlock:
mutex_unlock(&tb->lock); mutex_unlock(&tb->lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment