Skip to content

Commit

Permalink
drivers/usb/core/driver: check return value of usb_set_interface()
Browse files Browse the repository at this point in the history
Check return value of usb_set_interface() and report error if it fails.
Otherwise usb_set_interface() may fail without any warnings.

This flaw was found using an experimental static analysis tool we are
developing. Report warnings when the function usb_set_interface() fails
can increase the dianosability.

Signed-off-by: Li Zhong <floridsleeves@gmail.com>
  • Loading branch information
FloridSleeves authored and intel-lab-lkp committed Sep 9, 2022
1 parent d818320 commit 720d6f8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/usb/core/driver.c
Expand Up @@ -1332,8 +1332,10 @@ static int usb_resume_interface(struct usb_device *udev,

/* Carry out a deferred switch to altsetting 0 */
if (intf->needs_altsetting0 && !intf->dev.power.is_prepared) {
usb_set_interface(udev, intf->altsetting[0].
desc.bInterfaceNumber, 0);
status = usb_set_interface(udev, intf->altsetting[0].desc.bInterfaceNumber, 0);
if (status < 0)
dev_err(intf->dev, "usb_set_interface error %d\n",
status);
intf->needs_altsetting0 = 0;
}
goto done;
Expand Down

0 comments on commit 720d6f8

Please sign in to comment.