Skip to content

usbreset: return failure when device reset fails - #257

Open
JeffLepp wants to merge 1 commit into
gregkh:masterfrom
JeffLepp:fix-usbreset-exit-status
Open

usbreset: return failure when device reset fails#257
JeffLepp wants to merge 1 commit into
gregkh:masterfrom
JeffLepp:fix-usbreset-exit-status

Conversation

@JeffLepp

@JeffLepp JeffLepp commented Sep 1, 2026

Copy link
Copy Markdown

Fixes #256: usbreset currently prints an error but returns success when either open() or USBDEVFS_RESET fails.

This PR makes reset_device() return failure for both error paths and return success only after USBDEVFS_RESET completes successfully.

Testing

  • Compiled usbreset.c with GCC using warnings as errors.
  • Injected an EACCES failure into open(); the exit status was 1.
  • Injected an EIO failure into USBDEVFS_RESET; the exit status was 1.
  • Successfully reset my attached Epson Perfection V39; the exit status was 0

Looking through the history, it appears the original usbreset behavior returned a nonzero status when open() or the reset ioctl failed but that behavior may have been accidentally removed in the OpenWrt usability refactor in commit 'a02f015'.

usbreset currently returns success after a matching device is found
even if open() or USBDEVFS_RESET fails. This prevents scripts from
reliably detecting a failed reset.

Return EXIT_FAILURE for both failure paths and EXIT_SUCCESS only after
USBDEVFS_RESET succeeds.

Signed-off-by: Jefferson Kline <jeffersonkline@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

usbreset exits successfully when opening or resetting the device fails

1 participant