summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorAnssi Hannula <anssi.hannula@bitwise.fi>2022-03-03 14:08:57 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-04-15 15:17:57 +0300
commitd8f98a23b4adf82ad4cf1a14f080f93cff06af93 (patch)
treee1f85337049e7f98ff905914b9c351cd88cf9324 /drivers
parentb310e82e779f1ed2ec1f4df4af17e7ede0ad8fed (diff)
downloadlinux-d8f98a23b4adf82ad4cf1a14f080f93cff06af93.tar.xz
xhci: fix uninitialized string returned by xhci_decode_ctrl_ctx()
commit 05519b8589a679edb8fa781259893d20bece04ad upstream. xhci_decode_ctrl_ctx() returns the untouched buffer as-is if both "drop" and "add" parameters are zero. Fix the function to return an empty string in that case. It was not immediately clear from the possible call chains whether this issue is currently actually triggerable or not. Note that before commit 4843b4b5ec64 ("xhci: fix even more unsafe memory usage in xhci tracing") the result effect in the failure case was different as a static buffer was used here, but the code still worked incorrectly. Fixes: 90d6d5731da7 ("xhci: Add tracing for input control context") Cc: stable@vger.kernel.org Signed-off-by: Anssi Hannula <anssi.hannula@bitwise.fi> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> commit 4843b4b5ec64 ("xhci: fix even more unsafe memory usage in xhci tracing") Link: https://lore.kernel.org/r/20220303110903.1662404-4-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/host/xhci.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index a87a5d267c9c..4b05d767e08f 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -2452,6 +2452,8 @@ static inline const char *xhci_decode_ctrl_ctx(unsigned long drop,
unsigned int bit;
int ret = 0;
+ str[0] = '\0';
+
if (drop) {
ret = sprintf(str, "Drop:");
for_each_set_bit(bit, &drop, 32)