Message ID | 20220222134117.34844-2-anssi.hannula@bitwise.fi (mailing list archive) |
---|---|
State | Accepted |
Commit | 05519b8589a679edb8fa781259893d20bece04ad |
Headers | show |
Series | [1/2] xhci: fix garbage USBSTS being logged in some cases | expand |
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index ac91647195f6..a2fcefb5a0bb 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -2465,6 +2465,8 @@ static inline const char *xhci_decode_ctrl_ctx(char *str, unsigned int bit; int ret = 0; + str[0] = '\0'; + if (drop) { ret = sprintf(str, "Drop:"); for_each_set_bit(bit, &drop, 32)
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 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") Signed-off-by: Anssi Hannula <anssi.hannula@bitwise.fi> --- drivers/usb/host/xhci.h | 2 ++ 1 file changed, 2 insertions(+)