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: 90d6d5731d ("xhci: Add tracing for input control context")
Cc: [email protected]
Signed-off-by: Anssi Hannula <[email protected]>
Signed-off-by: Mathias Nyman <[email protected]>
commit 4843b4b5ec64 ("xhci: fix even more unsafe memory usage in xhci tracing")
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
This commit is contained in:
Anssi Hannula 2022-03-03 13:08:57 +02:00 • committed by Greg Kroah-Hartman
commit d8f98a23b4

View file

@ -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)