nuttx/drivers
Marco Casaroli 5a7f1b5005
Some checks are pending
Build Documentation / build-html (push) Waiting to run
MemBrowse Memory Report / changes-filter (push) Waiting to run
MemBrowse Memory Report / load-targets (push) Waiting to run
MemBrowse Memory Report / identical (push) Blocked by required conditions
MemBrowse Memory Report / analyze (push) Blocked by required conditions
drivers/syslog: fix syslog_write() returning -EIO on every write
syslog_write_foreach() compares an unsigned count against a signed
accumulator:

  size_t  nwritten     = 0;
  ssize_t nwritten_max = -EIO;
  ...
  if (nwritten > nwritten_max)
    {
      nwritten_max = nwritten;
    }
  return nwritten_max;

The usual arithmetic conversions promote nwritten_max to size_t, so -EIO
becomes 4294967291 on a 32-bit target, and the comparison is never true.
nwritten_max keeps its initial value and the function returns -EIO no
matter how many bytes actually went out.  Observed under gdb on a running
target: nwritten == 64, nwritten_max == -5, (nwritten > nwritten_max) == 0.

Most callers discard the result -- syslog() itself returns void -- so this
is normally invisible.  It becomes fatal when /dev/console is backed by
syslog_console_write(), because then stdio acts on it.
lib_fflush_unlocked() sees a negative return, sets __FS_FLAG_ERROR and
returns early, before resetting fs_bufpos.  The bytes have already been
emitted, but the buffer is never cleared, so every subsequent stdio call
re-flushes the same CONFIG_STDIO_BUFFER_SIZE bytes.  The console fills
with one repeated fragment and the system makes no further progress.

Reaching that state needs CONFIG_CONSOLE_SYSLOG=y together with no driver
claiming /dev/console ahead of syslog_console_init().  Three in-tree
defconfigs qualify: x86/qemu-i486:ostest, renesas/skp16c26:ostest and
x86_64/qemu-intel64:earlyfb.  The other 56 CONSOLE_SYSLOG configurations
have a serial console that registers /dev/console first, which is why this
has gone unnoticed.

Introduced by 1685e8ff7b ("syslog: avoid an infinite loop if one channel
fails"), which changed nwritten_max from size_t to ssize_t = -EIO so that
an all-channels-failed case could be reported.  Give nwritten the same type
so the comparison is signed, which preserves that intent: nwritten_max
stays -EIO only when no channel wrote anything.  nwritten is never negative,
so the remaining comparisons against buflen are unaffected.

Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>

Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-29 07:57:29 +02:00
..
1wire drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-07-13 12:08:01 +02:00
aie drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-07-13 12:08:01 +02:00
analog drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-07-13 12:08:01 +02:00
audio drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-07-13 12:08:01 +02:00
bch drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-07-13 12:08:01 +02:00
can drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-07-13 12:08:01 +02:00
clk !include/fcntl.h: align open flags with Linux values 2026-06-30 13:43:44 +08:00
contactless drivers/contactless: fix uninitialized uid leak in mfrc522_read 2026-07-13 19:50:57 +08:00
coresight drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-07-15 15:27:28 +08:00
crypto drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-07-13 12:08:01 +02:00
devicetree include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
dma drivers: migrate to SPDX identifier 2024-11-06 18:02:25 +08:00
dummy drivers: migrate to SPDX identifier 2024-11-06 18:02:25 +08:00
eeprom drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-07-13 12:08:01 +02:00
efuse drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-07-13 12:08:01 +02:00
i2c drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-07-13 12:08:01 +02:00
i2s drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-07-13 12:08:01 +02:00
i3c drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-07-15 15:27:28 +08:00
input drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-07-15 15:27:28 +08:00
ioexpander drivers/ioexpander/iso1i813t.c: fix error startup condition 2026-07-28 18:57:57 -04:00
ipcc drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-07-15 15:27:28 +08:00
lcd drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-07-15 15:27:28 +08:00
leds drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-07-15 15:27:28 +08:00
loop drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-07-15 15:27:28 +08:00
math drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-07-15 15:27:28 +08:00
misc libs/libc: Fix divide-by-zero in stat() with large filesystem block sizes 2026-07-16 23:37:22 +08:00
mmcsd drivers/mmcsd: fix eMMC bus width switch sequencing 2026-07-23 15:26:05 +08:00
modem drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-07-15 15:27:28 +08:00
motor drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-07-15 15:27:28 +08:00
mtd libs/libc: Fix divide-by-zero in stat() with large filesystem block sizes 2026-07-16 23:37:22 +08:00
net drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-07-15 15:27:28 +08:00
note drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-07-15 15:27:28 +08:00
pci drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-07-15 15:27:28 +08:00
pinctrl drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-07-15 15:27:28 +08:00
pipes drivers/: Multiple Drivers Are Registered With World Writable Part 3 2026-07-16 09:49:07 -03:00
power drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-07-15 15:27:28 +08:00
rc drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-07-15 15:27:28 +08:00
regmap include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
reset include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
rf drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-07-15 15:27:28 +08:00
rpmsg drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-07-15 15:27:28 +08:00
rptun drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-07-15 15:27:28 +08:00
segger drivers/segger: Download systemview from NuttX Mirror Repo 2026-06-03 19:19:24 +08:00
sensors drivers/sensors: add LIS3DSH accelerometer uORB driver 2026-07-25 14:45:40 +02:00
serial drivers/serial: Modify serial/pty to allow NSH/Telnet line edit 2026-07-22 22:07:18 +08:00
spi drivers/spi/ice40: fix operator precedence in final clock cycle count 2026-07-20 17:05:01 +08:00
syslog drivers/syslog: fix syslog_write() returning -EIO on every write 2026-07-29 07:57:29 +02:00
thermal include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
timers drivers/watchdog: fix capture automonitor notifier context 2026-07-17 14:59:47 +08:00
usbdev drivers/usbdev/cdcncm: send TX immediately, not after a tick-quantized delay 2026-07-28 12:39:39 +02:00
usbhost libs/libc: Fix divide-by-zero in stat() with large filesystem block sizes 2026-07-16 23:37:22 +08:00
usbmisc drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-07-15 15:27:28 +08:00
usbmonitor include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
usrsock drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-07-15 15:27:28 +08:00
vhost include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
video drivers/video: zero message on MIPI DSI driver 2026-07-24 20:57:57 -03:00
virtio drivers/: Multiple Drivers Are Registered With World Writable Part 3 2026-07-16 09:49:07 -03:00
wireless drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-07-15 15:27:28 +08:00
.gitignore build: Remve the unnecessary .gitignore 2020-05-23 18:00:40 +01:00
CMakeLists.txt drivers: migrate to SPDX identifier 2024-11-06 18:02:25 +08:00
drivers_initialize.c serial/uart_rpmsg: add _raw version of driver 2026-02-23 09:19:57 -03:00
Kconfig espressif/rmt: replace rmtchar with arch-specific lirc adapter 2026-04-04 11:18:32 -03:00
Makefile tools: fix stale archive members surviving a Kconfig-driven CSRCS change 2026-07-28 21:26:03 -03:00