From: Dan Carpenter <dan.carpenter@linaro.org>
To: gil.fine@linux.intel.com
Cc: linux-usb@vger.kernel.org
Subject: [bug report] thunderbolt: Allow USB3 bandwidth to be lower than maximum supported
Date: Wed, 17 Apr 2024 15:52:34 +0300 [thread overview]
Message-ID: <6289898b-cd63-4fb8-906a-1b6977321af9@moroto.mountain> (raw)
Hello Gil Fine,
Commit 25d905d2b819 ("thunderbolt: Allow USB3 bandwidth to be lower
than maximum supported") from Feb 12, 2024 (linux-next), leads to the
following Smatch static checker warning:
drivers/thunderbolt/tunnel.c:2113 tb_tunnel_alloc_usb3()
error: uninitialized symbol 'max_rate'.
drivers/thunderbolt/tunnel.c
2061 struct tb_tunnel *tb_tunnel_alloc_usb3(struct tb *tb, struct tb_port *up,
2062 struct tb_port *down, int max_up,
2063 int max_down)
2064 {
2065 struct tb_tunnel *tunnel;
2066 struct tb_path *path;
2067 int max_rate;
2068
2069 if (!tb_route(down->sw) && (max_up > 0 || max_down > 0)) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The patch adds this condition. If both of these are <= 0 then
max_rate is uninitialized.
2070 /*
2071 * For USB3 isochronous transfers, we allow bandwidth which is
2072 * not higher than 90% of maximum supported bandwidth by USB3
2073 * adapters.
2074 */
2075 max_rate = tb_usb3_max_link_rate(down, up);
2076 if (max_rate < 0)
2077 return NULL;
2078
2079 max_rate = max_rate * 90 / 100;
2080 tb_port_dbg(up, "maximum required bandwidth for USB3 tunnel %d Mb/s\n",
2081 max_rate);
2082 }
2083
2084 tunnel = tb_tunnel_alloc(tb, 2, TB_TUNNEL_USB3);
2085 if (!tunnel)
2086 return NULL;
2087
2088 tunnel->activate = tb_usb3_activate;
2089 tunnel->src_port = down;
2090 tunnel->dst_port = up;
2091 tunnel->max_up = max_up;
2092 tunnel->max_down = max_down;
2093
2094 path = tb_path_alloc(tb, down, TB_USB3_HOPID, up, TB_USB3_HOPID, 0,
2095 "USB3 Down");
2096 if (!path) {
2097 tb_tunnel_free(tunnel);
2098 return NULL;
2099 }
2100 tb_usb3_init_path(path);
2101 tunnel->paths[TB_USB3_PATH_DOWN] = path;
2102
2103 path = tb_path_alloc(tb, up, TB_USB3_HOPID, down, TB_USB3_HOPID, 0,
2104 "USB3 Up");
2105 if (!path) {
2106 tb_tunnel_free(tunnel);
2107 return NULL;
2108 }
2109 tb_usb3_init_path(path);
2110 tunnel->paths[TB_USB3_PATH_UP] = path;
2111
2112 if (!tb_route(down->sw)) {
--> 2113 tunnel->allocated_up = min(max_rate, max_up);
^^^^^^^^
2114 tunnel->allocated_down = min(max_rate, max_down);
^^^^^^^^
Uninitialized.
2115
2116 tunnel->init = tb_usb3_init;
2117 tunnel->consumed_bandwidth = tb_usb3_consumed_bandwidth;
2118 tunnel->release_unused_bandwidth =
2119 tb_usb3_release_unused_bandwidth;
2120 tunnel->reclaim_available_bandwidth =
2121 tb_usb3_reclaim_available_bandwidth;
2122 }
2123
2124 return tunnel;
2125 }
regards,
dan carpenter
next reply other threads:[~2024-04-17 12:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-17 12:52 Dan Carpenter [this message]
2024-04-25 10:43 ` [bug report] thunderbolt: Allow USB3 bandwidth to be lower than maximum supported Gil Fine
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6289898b-cd63-4fb8-906a-1b6977321af9@moroto.mountain \
--to=dan.carpenter@linaro.org \
--cc=gil.fine@linux.intel.com \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.