Commit graph zephyr/subsys
Author SHA1 Message Date
Matthias Alleman
520ff7452a net: sockets: tls: size PKTINFO control length to the cmsg written
dtls_tx() reserves a control buffer large enough for IPV6_PKTINFO, but
always passes the whole buffer as msg_controllen, also when it only
writes the smaller IP_PKTINFO cmsg. The rest of the buffer is zeroed,
so the stack reads it as a second cmsg with cmsg_len 0. For that cmsg
NET_CMSG_NXTHDR() returns the same cmsg again, so set_pkt_hoplimit()
in context_sendto() loops forever.

As in coap_server_sendto(), this happens on 64-bit targets with
16-byte z_max_align_t (x86_64, aarch64), where a second cmsghdr fits
after the IPv4 cmsg. A DTLS server then hangs on the first record it
sends to an IPv4 peer.

Set msg_controllen to NET_CMSG_SPACE() of the PKTINFO actually
written.

This regressed in commit 631a8ec97e ("net: coap_server: reply from
the correct local address").

Signed-off-by: Matthias Alleman <matthias.alleman@basalte.be>
2026-10-15 00:53:25 +02:00
Matthias Alleman
9598ab4fb7 net: coap_server: size PKTINFO control length to the cmsg written
coap_server_sendto() reserves a control buffer large enough for
IPV6_PKTINFO, but always passes the whole buffer as msg_controllen,
also when it only writes the smaller IP_PKTINFO cmsg. The rest of the
buffer is zeroed, so the stack reads it as a second cmsg with
cmsg_len 0. For that cmsg NET_CMSG_NXTHDR() returns the same cmsg
again, so set_pkt_hoplimit() in context_sendto() loops forever.

This happens when the space left after the IPv4 cmsg can hold a
cmsghdr. On 64-bit targets with 16-byte z_max_align_t (x86_64,
aarch64) the buffer is 48 bytes and a second header fits at offset
32. The CoAP server thread then spins on the first unicast IPv4
request and never replies. On native_sim/native/64 this hangs the
whole process. 32-bit targets such as Cortex-M are not affected,
because the remaining space is too small.

Set msg_controllen to NET_CMSG_SPACE() of the PKTINFO actually
written.

This regressed in commit 631a8ec97e ("net: coap_server: reply from
the correct local address").

Signed-off-by: Matthias Alleman <matthias.alleman@basalte.be>
2026-10-15 00:53:25 +02:00
Aric Radzin
e678cb4b04 mgmt: mcumgr: grp: transport_mgmt: Fix direction in get_other_transport
transport_mgmt_get_other_transport() checks for the outgoing direction
in both branches. Asking for the other side of a bridge's incoming
transport with the incoming direction returns NULL, while asking with
the outgoing direction returns it.

The direction is the role of the given transport in the bridge, as for
transport_mgmt_is_bridged() and transport_mgmt_get_bridge(), so check
for the incoming direction in the first branch.

Fixes #121953

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Aric Radzin <aric.radzin@gmail.com>
2026-10-15 00:46:49 +02:00
Aric Radzin
3798fb1d83 mgmt: mcumgr: grp: transport_mgmt: Release lock for unconnected bridge
transport_mgmt_disconnect_bridge() returns -ENOTCONN for a bridge that
is not connected without releasing the transport management lock.
With CONFIG_MCUMGR_GRP_TRANSPORT_LOCKING, which is enabled by default,
the next lock then blocks forever. The SMP layer takes the lock for
every request and response when transport management is enabled, so
MCUmgr stops processing.

Release the lock before returning.

Fixes #121952

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Aric Radzin <aric.radzin@gmail.com>
2026-10-15 00:46:25 +02:00
Sylvio Alves
c4a4a36353 llext: fix detached section addresses with copied text
A detached section stays in the ELF buffer, but its address was
derived from the text region, which is only right while the text
region is also used in place. When the text region is copied,
e.g. because a coarse PMP granularity leaves the buffer
misaligned, calls into a detached section jumped into the copy
and relocations targeting it were applied outside the copied
text region.

Mark detached sections in the section map and take their address
from the ELF buffer.

Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-10-14 21:31:11 +02:00
Robert Lubos
9c76602920 net: mdns_responder: Serialize external record updates with the readers
The responders walking the external records snapshot the count first
and read the pointer later, with nothing serializing them against
mdns_responder_set_ext_records(). Replacing or unregistering the table
in between makes the walk index the new pointer with the old count, and
an unregister returned while a response was still being built, so the
caller could free a table that was still in use. Guard the table with a
mutex held by the setter and for the whole record walk, so a returned
call means the records are no longer referenced.

Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-10-14 13:50:56 +02:00
Robert Lubos
8927bc3efb net: mdns_responder: Allow unregistering the external records
The header documents a NULL records pointer as the way to unregister
the external record table before freeing it, but the function rejected
it with -EINVAL. Accept NULL with a zero count and clear the table;
keep rejecting NULL with a non-zero count and a non-NULL pointer with
a zero count.

Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-10-14 13:50:56 +02:00
Jamie McCrae
6d13f0fae0 mgmt: mcumgr: grp: enum_mgmt: Fix not setting CBOR list size
Fixes an issue whereby the list size was set to 0 when using the
get details for groups command as it did not count the number of
groups it would be returning

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-10-14 13:50:12 +02:00
Martin Stumpf
380131c196 mgmt: mcumgr: grp: fs_mgmt: close empty files after transfer
The file of an upload or download was only closed after the transfer
when its length was non-zero, because a length of 0 also stands for an
unknown length, e.g. for an upload resumed at a non-zero offset. Empty
files were therefore kept open until the inactivity timeout. Whether
the length is known is now tracked separately.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Martin Stumpf <finomnis@gmail.com>
2026-10-14 13:47:55 +02:00
Martin Stumpf
72d6aa2abb mgmt: mcumgr: grp: stat_mgmt: encode 64-bit values
64-bit statistics were truncated to 32 bits, because they were encoded
with zcbor_uint32_put(). They are now encoded with zcbor_uint64_put().

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Martin Stumpf <finomnis@gmail.com>
2026-10-14 13:47:55 +02:00
Martin Stumpf
8cc56ac38f mgmt: mcumgr: grp: stat_mgmt: fix stat_mgmt_count()
stat_mgmt_count() passed a pointer to its counter pointer to
stats_walk(), so the counter of the caller was never incremented.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Martin Stumpf <finomnis@gmail.com>
2026-10-14 13:47:55 +02:00
Martin Stumpf
2af0d7de45 mgmt: mcumgr: grp: os_mgmt: fix unsigned taskstat priority
The "& 0xff" mask for unsigned taskstat priorities was applied to the
result of zcbor_uint32_put() instead of to the priority. Because of
operator precedence it also bound the conditional expression the wrong
way. Negative priorities are now reported as 0-255 again.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Martin Stumpf <finomnis@gmail.com>
2026-10-14 13:47:55 +02:00
Martin Stumpf
5a7c076078 mgmt: mcumgr: grp: fs_mgmt: truncate file on empty upload
Uploading an empty file did not truncate an existing file, because the
file was only opened and truncated when the request carried data. A
request at offset 0 is now always processed, and fs_write() is skipped
for zero-length data.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Martin Stumpf <finomnis@gmail.com>
2026-10-14 13:47:55 +02:00
Aric Radzin
bc9fd16c9d mgmt: mcumgr: transport: serial: Drop unused raw header parameter
mcumgr_serial_process_frag_raw() takes a struct smp_hdr pointer that it
only ever overwrites with the start of the received data before reading
it, and its caller passes an uninitialised variable. Clang reports this
with -Wuninitialized, which fails the build as soon as the raw framing
code is compiled with the LLVM toolchain.

Make the header pointer a local variable of the function, and drop the
parameter and the unused variable in its caller.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Aric Radzin <aric.radzin@gmail.com>
2026-10-14 13:47:37 +02:00
Robert Khanafiev
ed911f1dce usb: host: return an error code on configuration descriptor mismatch
When the configuration descriptor read mismatch occurs, the function
exits, but the error code still contains 0 from the previous successful
read, so the calling function is informed that the configuration was
successful, even though the real state wasn't updated.

This fix explicitly returns error code.

Signed-off-by: Robert Khanafiev <robert.khanafiev@fischer-electronic.com>
2026-10-14 13:45:58 +02:00
Johan Hedberg
2ae5593b9f bluetooth: classic: rfcomm: Fix reading the buffer after queueing it
bt_rfcomm_dlc_send() returns buf->len after it has put the buffer on
the DLC TX queue and scheduled the TX work. That work runs on the
Bluetooth workqueue, on another CPU or as soon as an interrupt preempts
the caller, and hands the buffer to L2CAP, which modifies and later
frees it. The returned byte count is then read from a buffer RFCOMM no
longer owns.

Read the length before queueing the buffer, and clear the pointer at
the handover with net_buf_take().

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-14 13:44:42 +02:00
Johan Hedberg
36b83f07e3 Bluetooth: Controller: Fix the CIS burst counter for burst number 15
The LLL marks the payloads of a burst as done by moving the current
burst number past the burst number, which the 4 bit field can not hold
for the largest burst number of 15. The counter wraps to 0 instead,
and the LLL goes on with the payload numbers of the previous burst.
Widen the field to 5 bits.

Tested for regressions with tests/bsim/bluetooth/ll/cis on nrf52_bsim.
No test with a burst number of 15 is added.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-14 08:44:59 +02:00
Johan Hedberg
c05b3a9b8e Bluetooth: Controller: Fix conn is_abort assert without event deferral
When neither 2M nor Coded PHY is enabled, EVENT_DEFER_MAX is 0 and the
TRX busy iteration maximum is 0 too. The debug assert in the central and
peripheral is_abort callbacks then fails every time a connection event
is cancelled by an overlapping event, e.g. when a connection event with
more data runs into the next connection interval.

Only check the iteration count when deferral is supported.

Tested for regressions with tests/bsim/bluetooth/ll/conn on nrf52_bsim.
No test of a build without the 2M and Coded PHYs is added.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-14 08:44:49 +02:00
Gero Schwäricke
27064e3a25 tracing: sysview: fix thread info swap
StackSize and StackBase were swapped and StackUsage was uninitialized.

While at it, I reduced code duplication.

Signed-off-by: Gero Schwäricke <gero.schwaericke@sevenlab.de>
2026-10-14 08:44:02 +02:00
Massimiliano Cialdi
41badc09d7 net: ptp: Fix the other uses of CONTAINER_OF on a received TLV
The previous commit fixed the CLOCK_DESCRIPTION parsing, which took the
TLV container with CONTAINER_OF() on the TLV itself instead of on the
tlv member of the container. Two more places did the same:
- the USER_DESCRIPTION parsing, which stored the description pointer
  inside the received message instead of in the container;
- ptp_tlv_pre_send() for a CLOCK_DESCRIPTION, used when a management
  message is forwarded to the other ports, which also converted the byte
  order of the clock_desc pointer variables instead of the fields they
  point to.

Give ptp_tlv_pre_send() the same pointer to the tlv member of the
container that ptp_tlv_post_recv() now takes, and get the container
from it in both places.

Add tests/net/ptp/tlv_mgmt, which runs tlv.c on a received
CLOCK_DESCRIPTION and USER_DESCRIPTION TLV and sends the first one on
again. Its three cases fail on main without the two commits.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Massimiliano Cialdi <massimiliano.cialdi@powersoft.com>
2026-10-14 08:42:27 +02:00
Markus Suing
395471c0aa net: ptp: Fix PTP_TLV_TYPE_MANAGEMENT / PTP_MGMT_CLOCK_DESCRIPTION
The PTP_TLV_TYPE_MANAGEMENT / PTP_MGMT_CLOCK_DESCRIPTION was
not working due to wrong use of CONTAINER_OF

Forward port of the v3.7-branch fix (#99673), which never reached main.
The test stubs of ptp_tlv_post_recv(), which main has and v3.7-branch
does not, follow the new signature.

Fixes #99527

(cherry picked from commit 889f556469)

Signed-off-by: Markus Suing <markussuing@eaton.com>
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Massimiliano Cialdi <massimiliano.cialdi@powersoft.com>
2026-10-14 08:42:27 +02:00
Arkadiusz Grzelka
2856edf906 Bluetooth: Controller: Calculate BIG control subevent channel ahead
When a BIG control PDU is pending, isr_rx() calls lll_chan_iso_event()
before starting the radio for the control subevent. The extra work
before radio_tmr_start_us() can make the start late and trip its
LL_ASSERT_ERR().

Calculate the control subevent channel in next_chan_calc_seq() and
next_chan_calc_int(), after the radio start of the last data subevent
is set up. When isr_rx() skips the remaining data subevents, or the last
BIS is not synchronized, isr_rx() still calculates the channel before
the start, as before.

Tested on two nRF5340 Audio DKs with zephyrproject-rtos/zephyr#120919
applied: without this change, a sink following a source that re-creates
its BIG hit the assert within six terminations in both runs.

Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Arkadiusz Grzelka <devitwise@gmail.com>
2026-10-14 08:41:13 +02:00
Arkadiusz Grzelka
3ae8217cf7 Bluetooth: PACS: Fix notify property of Sink and Source PAC
The Sink and Source PAC characteristics set the notify property under
CONFIG_BT_PAC_SNK_LOC_NOTIFIABLE and CONFIG_BT_PAC_SRC_LOC_NOTIFIABLE,
but their CCCD follows CONFIG_BT_PAC_SNK_NOTIFIABLE and
CONFIG_BT_PAC_SRC_NOTIFIABLE.

With only the PAC option set, a client's CCCD write is rejected with
CCC Improper Configuration. With only the location option set, the
property has no CCCD behind it.

Gate the property on the PAC option.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Arkadiusz Grzelka <devitwise@gmail.com>
2026-10-14 08:40:58 +02:00
Martin Meyer
ee29018544 mgmt: mcumgr: handle partially accepted image uploads
Use the offset returned by the target to determine how many image bytes
were actually written instead of assuming that the complete requested
payload was accepted.

An SMP frame commonly carries up to 340 bytes of image data, but a target
may accept fewer bytes, for example 336 bytes, when the flash write size
must be aligned to a 16-byte boundary. Account for this behavior so the
client advances its source buffer by the target-confirmed amount and
continues the upload without losing data.

Signed-off-by: Martin Meyer <meyer.m90@gmail.com>
2026-10-13 14:12:24 -05:00
Takumi Ando
8261d17dcd shell: rpmsg: Add option to force blocking TX
The RPMsg shell normally uses non-blocking sends during regular operation.
When all TX buffers are in use, rpmsg_trysend() fails and the shell core
cannot retry the output because the backend has no TX completion callback.

Add an option to force the existing blocking mode so applications can wait
for an available RPMsg TX buffer when output loss is not acceptable.

Signed-off-by: Takumi Ando <takumi@spacecubics.com>
2026-10-13 14:11:10 -05:00
Aleksandr Khromykh
d86ca41a93 bluetooth: mesh: sequence store rate configuration fix
Commit fixes configuration of the sequence store rate.
KConfig picks up the first met default option.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2026-10-13 17:13:19 +02:00
Johan Hedberg
81be40fd71 Bluetooth: L2CAP: Fix TX stall after 0 initial credits
An LE credit-based connection request or response may carry 0 initial
credits. l2cap_chan_tx_give_credits() still set BT_L2CAP_STATUS_OUT for
such a grant, reporting the channel as sendable. An SDU queued before the
peer granted credits then never went out: l2cap_data_pull() dropped the
channel from the ready list for lack of credits, and the first real grant
found the bit already set and did not add the channel back.

Ignore grants of 0 credits, so that the first real grant sets the bit and
resumes TX.

Fixes #121544

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-13 17:08:02 +02:00
Aric Radzin
c4ccaa5216 drivers: console: uart_mcumgr: Fix async RX timeout Kconfig
CONFIG_MCUMGR_TRANSPORT_UART_ASYNC=y fails to build unless the
unrelated CONFIG_UART_CONSOLE_MCUMGR=y is also set. The RX timeout added
by commit 3b9cd7b9cb ("drivers: console: uart_mcumgr: Add async
timeout") is defined under UART_CONSOLE_MCUMGR, the UART console's
MCUmgr passthrough, so CONFIG_UART_CONSOLE_MCUMGR_ASYNC_RX_TIMEOUT_US
is undefined in any other configuration.

Move the option next to the other MCUmgr UART async options as
MCUMGR_TRANSPORT_UART_ASYNC_RX_TIMEOUT_US, under
MCUMGR_TRANSPORT_UART_ASYNC, which guards the driver code that uses
it. The prompt, default and help text are unchanged. The option has
not been in a release, so it is renamed without a deprecation period.

Tested by building samples/subsys/mgmt/mcumgr/smp_svr for
nrf52840dk/nrf52840 with serial.conf and the asynchronous UART API,
which fails without this change.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Aric Radzin <aric.radzin@gmail.com>
2026-10-12 23:33:59 +02:00
Johan Hedberg
9f4f79b3aa Bluetooth: Host: Fix command left waiting when bt_disable() closes HCI
bt_disable() completes the commands that are still queued when it
closes the HCI transport, but not the one that has been handed to the
driver. A command that another thread sends while bt_disable() waits
for the controller to be reset is transmitted once the controller has
responded to the reset. The transport is then closed before the
response to the command arrives, and its sender waits for the command
timeout, which ends in an assertion.

Complete the command in flight with an error once the transport has
been closed, since nothing can respond to it any more.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-12 23:26:05 +02:00
Johan Hedberg
12881504fd Bluetooth: Host: Fix deadlock when the driver fails to send data
When send_buf() fails, typically because the HCI driver failed to send
the packet, the TX processor gives the connection up and disconnects
it. bt_conn_disconnect() waits for its HCI command, and the TX
processor is what transmits commands: with
CONFIG_BT_TX_PROCESSOR_THREAD, the default, it waits for a command
that it cannot send, holding the host lock, until the command times
out and the Host asserts.

Leave the disconnecting to the Bluetooth workqueue, which can wait for
the command. The connection is flagged for it, and the TX processor
passes a flagged connection over for as long as it is connected, so
that nothing more is sent on it while it is being disconnected. A
connection that is still connected after that, because the command
failed, loses the flag and goes on sending. A disconnected one loses
it too, as a central CIS keeps its object for its next connection.

A BIS is left alone: it cannot be disconnected on its own, and
terminating its BIG would take the other BISes down too. What failed
to go out on it is lost, and sending goes on.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-12 23:26:05 +02:00
Johan Hedberg
861b8a6bcc Bluetooth: Host: Fix deadlock when data is sent during bt_disable()
bt_disable() clears BT_DEV_READY and then waits for the controller to
be reset, with the connections still in place since
commit 78ea662dfe ("Bluetooth: Host: Reset controller before conn
teardown in bt_disable()"). Data sent meanwhile is dropped by
send_buf(), the Host being no longer ready, which the TX processor
takes for a fatal error and answers by disconnecting the connection.
That is a synchronous HCI command issued from the thread that
transmits commands, so it waits for a command that it cannot send, and
does so holding the host lock. With CONFIG_BT_SMP bt_disable() takes
that lock once the controller has been reset and never gets to purge
the command queue, which would have ended the wait: both threads stay
blocked until the command times out and the Host asserts.

Seen with auto-pts, which powers the tester off while a broadcast
source is streaming.

Have the TX processor pass over the connections while the Host is not
ready, before it takes anything from them. What is queued stays where
it is until bt_disable() tears the connections down, as for any
connection that goes away with data queued, or until the Host is ready
again after a failed reset, which now restarts the TX processor.

That replaces the check in send_buf(), which came too late: the upper
layer had by then accounted for the data as handed over, and the
failure was reported to a callback running in the TX processor.
bt_disable() now clears BT_DEV_READY under the host lock, which the TX
processor holds for a whole pass, so that the flag does not change
under a pass that another thread is in the middle of.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-12 23:26:05 +02:00
Hongquan Li
a0fd322c98 fs: ext2: roll back inode allocation when creation fails
New inode allocation remains committed when file or directory creation
fails after allocation. The caller only drops the in-memory reference; the
inode remains allocated on disk.

Keep removal pending until initial creation succeeds. Mark later creation
failures for cleanup through the existing inode-drop path.

Fixes #118139

Signed-off-by: Hongquan Li <hongquan.li@processmission.com>
2026-10-11 18:54:51 +02:00
Hongquan Li
b0f71069a1 fs: ext2: define cleanup semantics after failed close
The close path returns early when inode sync or drop fails, leaving the
file slab object and public file handle allocated. An abandoned handle can
then exhaust the ext2 file and inode pools.

Always attempt inode cleanup and release the file object. Treat a repeated
close of the cleaned handle as a no-op so the public handle can be cleared.

Fixes #118141

Signed-off-by: Hongquan Li <hongquan.li@processmission.com>
2026-10-11 18:54:39 +02:00
Hongquan Li
89a0e07d55 fs: ext2: handle allocation errors safely during format
Formatting dereferences inode-table block allocations without checking
them, and two directory allocation failures return positive ENOMEM.
Format callers only recognize negative errors, so either case can fault or
report a failed format as successful.

Check allocations before use and return -ENOMEM for allocation failures.

Fixes #118138

Signed-off-by: Hongquan Li <hongquan.li@processmission.com>
2026-10-11 18:54:14 +02:00
Hongquan Li
2395697adc fs: ext2: do not skip inodes while unmounting
ext2_inode_drop() compacts the inode pool after removing an entry, so an
increasing close-loop index skips the entry moved into that slot. The close
path also returns before releasing group blocks when metadata commit fails.

Process compacted entries at the current index and preserve cleanup errors.
Always release group blocks and synchronize the backend.

Fixes #118140

Signed-off-by: Hongquan Li <hongquan.li@processmission.com>
2026-10-11 18:53:34 +02:00
Hongquan Li
77a32a3976 fs: ext2: release temporary blocks on metadata write failure
The metadata commit helpers return before releasing the temporary block
when ext2_write_block() fails. This leaks slab allocations on each failed
metadata write.

Drop the block before returning the write error.

Fixes #118137

Signed-off-by: Hongquan Li <hongquan.li@processmission.com>
2026-10-10 22:46:59 +02:00
Benjamin Cabé
1de8b32703 usb: device_next: guard High-Speed configuration in the shell
udc_virtual reports High-Speed from devicetree alone, so on a
Full-Speed-only build "usbd defaults" added a High-Speed configuration
and failed with -ENOTSUP. Guard it with USBD_SUPPORTS_HIGH_SPEED, as
sample_usbd_init.c already does.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5
2026-10-10 20:07:02 +02:00
Benjamin Cabé
1ebccbf456 pm: trace the state actually entered on suspend exit
pm_system_resume() clears z_cpus_pm_state[id] before the system_suspend
exit hook reads it, so every successful suspend was traced as
PM_STATE_ACTIVE. Latch the state before entering it and report that.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5.5
2026-10-10 13:00:13 +02:00
Hongquan Li
62cb7a7f03 fs: ext2: preserve partial I/O results after block errors
The inode read and write paths return a later block error after
earlier bytes have completed. The file wrapper therefore leaves its offset
despite completed write data already being persisted.

Return completed byte counts after later block errors and persist the size
reached by completed writes.

Fixes #118142

Signed-off-by: Hongquan Li <hongquan.li@processmission.com>
2026-10-10 12:59:59 +02:00
Zhijie Zhong
840bde98df Bluetooth: SMP: clear LinkKey distribution bits after legacy pairing
bt_smp_encrypt_change() clears BT_SMP_DIST_LINK_KEY inside its Secure
Connections branch, and the comment there already says these bits double
as the pairing-finished indicator. On the legacy path the bit is never
cleared, so with CONFIG_BT_CLASSIC=y and CONFIG_BT_SMP_SC_PAIR_ONLY=n,
against a peer that sets LinkKey while Secure Connections is not
selected, local_dist keeps BT_SMP_DIST_LINK_KEY after key distribution
has finished. The `if (!smp->local_dist && !smp->remote_dist)` checks
never become true, smp_pairing_complete() is never called, and the SMP
timeout eventually reports the pairing as failed even though the link is
encrypted and the keys were exchanged.

Move the clearing out of the Secure Connections branch, leaving only
SMP_FLAG_DERIVE_LK inside it. A link key can only be derived from a
Secure Connections LTK, so the bit has nothing to signal on the legacy
path. Nothing on air changes.

Signed-off-by: Zhijie Zhong <zhongzhijie1@xiaomi.com>
Assisted-by: Kiro:claude-opus-5
2026-10-10 12:59:46 +02:00
Johan Hedberg
83d85095c4 Bluetooth: Classic: L2CAP: Fix PSM left on connless buffer on failure
bt_l2cap_br_connless_send() adds the PSM to the buffer before sending,
and returned the buffer to the caller with the PSM still added when
sending failed, although the caller keeps the buffer on error.

Remove the PSM again when sending fails, and document that the caller
gets the buffer back unchanged.

Tested with tests/bluetooth/host_l2cap_br_send on native_sim.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-10 06:52:47 +02:00
Johan Hedberg
4218544d7e Bluetooth: Classic: L2CAP: Fix header left on buffer after failed send
In basic mode, bt_l2cap_br_send_cb() added the L2CAP header before
checking that the buffer's user data has room for the send callback.
When that check failed, the caller, who keeps the buffer on error, got
it back with the header added, for example from bt_l2cap_chan_send().

Check the user data before adding the header.

Tested with tests/bluetooth/host_l2cap_br_send on native_sim.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-10 06:52:47 +02:00
Benjamin Cabé
647f444ded llext: use the MMU page size only on targets with an MMU
Espressif SoCs set CONFIG_MMU_PAGE_SIZE to 64 KB for their flash cache
MMU without enabling CONFIG_MMU. With the RISC-V PMP enabled, as on
ESP32-H2, the memblk heap block size then has to be a multiple of 64 KB
and the llext.readonly_mmu.memblk build fails a static assertion. Take
LLEXT_PAGE_SIZE from CONFIG_MMU_PAGE_SIZE only when CONFIG_MMU is set.

Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-10-09 21:31:10 +02:00
Holt Sun
42d1f06a35 pm: clarify experimental timer resume and gate its tests
Mark the early system timer resume prompt as experimental and remove
redundant resume-ordering notes from the PM documentation.

Use CMake's LINKER syntax for the timer idle-exit wrapper. Restrict
the two timer-order tests to GNU ld or LLD toolchains, and explain
why they require SysTick without an LPM companion.

Keep both PM resume sequences unchanged.

All five power management configurations were built and run on
qemu_cortex_m3 with the GNU toolchain; all 48 tests passed.

Signed-off-by: Holt Sun <holt.sun@nxp.com>
2026-10-09 16:59:33 +02:00
Holt Sun
3ffa4f7a4f pm: gate early system timer resume behind an experimental option
Restore the legacy system PM resume sequence by default: resume
system-managed devices, run SoC exit post-ops, notify state exit,
and perform system timer idle-exit accounting.

Keep the sequence introduced by #118977 behind the default-off
PM_EARLY_SYSTEM_TIMER_RESUME option, which selects EXPERIMENTAL.
Platforms enabling it must validate SoC and timer dependencies and
timeout callbacks that can run before devices have resumed. The
legacy sequence retains its stopped-timer busy-wait limitation.

Leave STM32 LPTIM unchanged and document both resume sequences. Add
QEMU tests for exact resume ordering, IRQ masking, and timer progress
during device resume.

All 48 tests across five QEMU configurations pass. Build STM32U5
STOP3 and STM32WBA S2RAM. Validate both sequences on FRDM-MCXN947
for ten S2RAM cycles each, including busy-waits in experimental
device resume callbacks. STM32 runtime validation remains pending.

Signed-off-by: Holt Sun <holt.sun@nxp.com>
2026-10-09 16:59:33 +02:00
Ludvig Jordet
3f878df514 Bluetooth: Mesh: Decouple RPL store timeout from storage mode
Solve two issues:

  * Other storage modes than CONFIG_BT_MESH_RPL_STORAGE_MODE_SETTINGS
    could not reuse the pending store scheduler used by the settings
    backend.
  * The store timing of SRPL, which is always stored through the
    Settings subsystem, would use CONFIG_BT_MESH_RPL_STORE_TIMEOUT if
    RPL was also stored in settings via
    CONFIG_BT_MESH_RPL_STORAGE_MODE_SETTINGS, but not if another storage
    mode was used for RPL.

Decouple the store scheduler from the Settings subsystem and the
chosen RPL storage mode, so the scheduler code and the separate
CONFIG_BT_MESH_RPL_STORE_TIMEOUT option are

a) Available regardless of storage mode, and always used for SRPL when
set and
b) Available without CONFIG_BT_SETTINGS, in case an RPL storage mode
does not need Settings but would like the scheduling.

Also change the BT_MESH_SETTINGS_RPL_RESET_PENDING to always store
immediately. This was in practice already the case whenever settings was
used, since this was only ever scheduled right before a second NO_WAIT
configuration was scheduled (like net key, IV, etc.). Now this behavior
is consistent both with and without BT_SETTINGS enabled.

Assisted-by: Copilot:claude-sonnet-5.5
Signed-off-by: Ludvig Jordet <ludvig.jordet@nordicsemi.no>
2026-10-09 16:58:06 +02:00
Fin Maaß
91ddb11aa4 net: imply NET_DRIVERS when needed
when using qemu we only need NET_DRIVERS,
when slip or ppp are used.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-10-09 16:57:30 +02:00
Martin Meyer
4e4caba48a mgmt: mcumgr: select MCUboot bootutil library
Enable the MCUboot bootutil library when the MCUmgr image management
server or client is enabled.

Add a Zephyr-side Kconfig option for linking applications with the
MCUboot bootutil headers and select the bootutil library from the
MCUmgr image management Kconfig symbols.

This ensures the required bootutil dependency is enabled automatically
for MCUmgr image management functionality.

Signed-off-by: Martin Meyer <meyer.m90@gmail.com>
2026-10-09 16:56:09 +02:00
Vandra-Meyer Akos
132586a433 Bluetooth: Host: Fail bt_enable() when the Controller never responds
When the Controller is missing, unpowered or does not run HCI, the first
command that bt_enable() sends times out, and the Host asserts:

  ASSERTION FAIL [err == 0] @ .../bluetooth/host/hci_core.c:572
  	Controller unresponsive, command opcode 0x0c03 timeout with err -11

An application cannot handle this, so Bluetooth cannot be optional at run
time, for example on a board with the Controller on a plug-in module.

The Host now records whether the Controller has sent a packet while
bt_enable() runs. When bt_hci_cmd_send_sync() times out waiting for a
response during bt_enable(), and the Controller has not sent anything,
the Host closes the transport, as bt_disable() does, and bt_enable() fails
with -ETIMEDOUT. The close stops a late response from completing a
command whose sender has returned. Because the transport is closed,
bt_enable() can be called again. This also applies to a command that the
TX processor thread never sends, such as HCI Reset with CONFIG_BT_WAIT_NOP
when no NOP arrives: the close completes it.

The Host still asserts when a command times out after the Controller has
responded. Such a Controller is present but faulty, and once packets have
come in, a clean failure needs the RX teardown that bt_disable() does. The
record is kept across HCI Reset, so a Controller that answers HCI Reset
and then stops also causes the assert. The Host also asserts when the
driver cannot close the transport, and, without
CONFIG_BT_TX_PROCESSOR_THREAD, when a command sent from the system work
queue cannot be sent.

The transport must not be closed while the driver is in send(), and a
send() can outlast the command timeout. The TX processor holds the host
lock during send(), so the Host takes the lock without waiting before it
closes the transport. When the lock is not free, the Host asserts.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Vandra-Meyer Akos <akos@lvgl.io>
2026-10-09 16:55:07 +02:00
Ryan Erickson
1783873470 Bluetooth: fix format specifiers for size_t/ssize_t
Several LOG_ and __ASSERT format strings use %u or %d for arguments
that are size_t or ssize_t, which produces -Wformat= warnings on
LP64 targets (e.g. AArch64). Switch to %zu / %zd.

* subsys/bluetooth/host/classic/sdp.c: three format strings that
  compare against sizeof() or use ssize_t counters.

* drivers/bluetooth/hci/hci_nxp_setup.c: matching V1 and V3
  "Out of sending buffer range" messages (both LOG_ERR and the
  neighbouring __ASSERT that uses the same string).

No functional change; eliminates 5 build warnings on
nitrogen93_smarc/mimx9352/a55/nx611.

Assisted-by: Claude:claude-opus-4.7
Signed-off-by: Ryan Erickson <ryan.erickson@ezurio.com>
2026-10-09 16:49:48 +02:00