#1135899 dfu-util intermittently exits with error-code 251 after successfully updating device.

Package:
dfu-util
Source:
dfu-util
Description:
Device firmware update (DFU) USB programmer
Submitter:
Kor Nielsen
Date:
2026-05-07 08:19:02 UTC
Severity:
normal
#1135899#5
Date:
2026-05-07 08:17:22 UTC
From:
To:
Dear Maintainer,

This tool intermittently exits with error code 251 after performing a
successful update. This occurs because `libusb_reset_device()` returns
`LIBUSB_ERROR_NOT_FOUND`, which can happen on some devices. There is a
fix available upstream:
https://sourceforge.net/p/dfu-util/dfu-util/ci/4800abbf917c7e10db495004b4dfbe366b429867

Upstream has not released a version with this fix in the 3 years since
it was committed. I believe debian users could benefit from patching
this fix into unstable:

commit 4800abbf917c7e10db495004b4dfbe366b429867
Author: Francesco Dolcini <francesco.dolcini@toradex.com>
Date:   Tue May 23 09:47:08 2023 +0200

    main: Return success if final reset fails due to device gone

    Return with success when libusb_reset_device() returns
    LIBUSB_ERROR_NOT_FOUND. Without this change 251 (LIBUSB_ERROR_NOT_FOUND
    = -5) would be returned to the shell.

    Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>

diff --git a/src/main.c b/src/main.c
index 962c2a1..25812b4 100644
--- a/src/main.c
+++ b/src/main.c
@@ -781,6 +781,8 @@ status_again:
  if (ret < 0 && ret != LIBUSB_ERROR_NOT_FOUND) {
  warnx("error resetting after download: %s", libusb_error_name(ret));
  ret = EX_IOERR;
+ } else {
+ ret = EX_OK;
  }
  }


Thanks for your attention!

Kor