bt_avdtp_connect() and bt_avdtp_l2cap_accept() store the connection
pointer in the session, and only then initialize session->sem_lock.
The connection pointer is what makes the session visible to other
contexts, and the upper layer clears the whole session structure when
it is reused, so between the two the session can be reached with a
zero-initialized semaphore.
Initialize the semaphore before the session is published, while the
global lock is still held.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
bt_avdtp_register_sep() calls bt_avdtp_set_state_lock() while holding
the global avdtp_sem_lock, i.e. it takes avdtp_sem_lock and then
sep->sem_lock. The command handlers use the opposite order: they run
with sep->sem_lock held and take avdtp_sem_lock when queuing the
response for transmission (avdtp_send_rsp() -> avdtp_send_common()).
Registering an endpoint while signalling is in progress can therefore
deadlock.
The endpoint has not been added to the `seps` list at that point, so no
other context can reach it. Set the state without taking sep->sem_lock.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
The BIP transport disconnected callbacks for the Cover Art Target and
Controller unreference tg->conn and ct->conn without clearing the
pointers. The API functions in this file rely on a conn == NULL check
to detect that the Cover Art channel is not connected, so after a
transport disconnect these checks pass with a dangling pointer. Since
connection objects are recycled, the stale pointer may also end up
aliasing an unrelated live connection.
Use bt_conn_drop(), which unreferences the connection and clears the
pointer, keeping the not-connected checks in the API functions sound.
Assisted-by: Claude:claude-fable-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
The BT HCI endpoint buffers are limited to USBD_MAX_BULK_MPS, which is
64 bytes on full-speed controllers. Configured HCI ACL or event packets
can be larger, causing an assertion or buffer overflow when copied.
Use separate IN and OUT pools. Size the IN pool for the largest configured
HCI packet and keep the OUT pool limited to USBD_MAX_BULK_MPS. This allows
each HCI packet to be submitted in one USB request without increasing all
endpoint buffers.
Signed-off-by: Dominik Michalczyk <dominik.michalczyk@nordicsemi.no>
Add a new TLS socket option, TLS_MAX_FRAGMENT_LENGTH, which allows to
configure the RFC 6066 Maximum Fragment Length extension per socket,
overriding the global value derived from compile-time buffer sizes.
Valid values (TLS_MFL_DISABLED through TLS_MFL_4096) map directly to
Mbed TLS MBEDTLS_SSL_MAX_FRAG_LEN_* codes. TLS_MFL_DEFAULT (-1) resets
a socket back to the global auto-derived value.
Remove the restriction that prevented advertising MFL when the
compile-time buffer sizes are at the TLS maximum. True constraints are
enforced by the mbedTLS layer below.
NET_SOCKETS_TLS_SET_MAX_FRAGMENT_LENGTH now depends on
MBEDTLS_SSL_MAX_FRAGMENT_LENGTH, so this option cleanly compiles away
on builds where Mbed TLS's own MFL support is not available, instead
of silently having no effect.
Signed-off-by: Kacper Szkoda <kacperszkodaib@gmail.com>
Closing a socket in another thread can lead to use-after-free issues on
`native_sim` when that socket is being used in epoll. This fix ensures
that closing the socket is always done in the coap server thread,
ensuring no race on the sockets occurs
Assisted-by: Claude:claude-opus-4.8
Signed-off-by: Jose Ignacio Biehl Ulate <joseignacio.biehlulate@draeger.com>
When vbuf is NULL, the LOG_ERR unconditionally dereferences
vbuf->index. Split the NULL check from the index bounds check.
Tests:
- test_video_buffer_release_null
- test_video_buffer_alloc_release
- test_video_buffer_release_bad_index
Signed-off-by: Yiren Guo <guoyr_2013@hotmail.com>
Replace manual for loops iterating over fixed-size arrays with the
ARRAY_FOR_EACH macro for consistency with the rest of the codebase.
The following loops are converted:
- mce_mas_select(): iterate mce_mas_instances[index]
- mse_mas_select(): iterate mse_mas_instances[index]
- mse_mns_find(): iterate mse_mns_instances
Signed-off-by: Can Wang <can.wang@nxp.com>
The GetMessage operation was missing required application parameters
in its validation macro. According to the MAP specification, the
Attachment and Charset parameters are mandatory for GetMessage
requests.
Add BT_MAP_APPL_PARAM_TAG_ID_ATTACHMENT and
BT_MAP_APPL_PARAM_TAG_ID_CHARSET to GET_MSG_REQUIRED_AP to ensure
these parameters are validated by has_required_app_params().
Signed-off-by: Can Wang <can.wang@nxp.com>
The MCE MAS connect commands could allow multiple connections to the
same MAS instance ID to be established, leading to resource conflicts.
Fix this by checking if a connection to the requested instance ID
already exists before allocating a new MCE MAS instance in both
bt_map_mce_mas_rfcomm_connect() and bt_map_mce_mas_l2cap_connect()
shell commands.
The MSE MAS accept callbacks could allow multiple connections of the
same transport type (RFCOMM or L2CAP) to be established for a single
MAS instance.
Fix this by validating both the PSM and RFCOMM channel in the accept
callbacks and rejecting duplicate connection attempts.
Signed-off-by: Can Wang <can.wang@nxp.com>
For client roles (MCE MAS and MSE MNS), remove the dedicated
*_cb_register() functions and pass the callback pointer directly
to rfcomm_connect() / l2cap_connect() calls, matching the pattern
used by the PBAP and BIP client APIs.
For server roles (MCE MNS and MSE MAS), rename *_cb_register() to
*_register(). The new function both stores the callback table and
registers the instance with the underlying OBEX server. The
accept() callbacks no longer register callbacks per-connection;
callers must invoke *_register() once before registering the
transport server.
Add shell commands `map mce mns register` and `map mse mas
register`, and update the shell documentation accordingly.
Signed-off-by: Can Wang <can.wang@nxp.com>
Add checks for `BT_DEV_READY` flag in Bluetooth Classic (BR/EDR) API
functions to prevent operations before the Bluetooth stack is fully
initialized.
The following functions now return `-EAGAIN` if called before the stack
is ready, including functions `bt_br_discovery_start()`,
`bt_br_set_connectable()`, `bt_br_set_discoverable()`, and
`bt_br_write_eir()`.
For the function `bt_conn_create_br()`, it returns `NULL` if the stack
is not ready.
The changes prevent potential issues from attempting BR/EDR operations
before the controller and host are properly initialized.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Check that a transport data message for an unknown receiver index, which
cannot be authenticated, does not move the peer endpoint, and that the
stale session recovery handshake is still triggered towards the endpoint
we already know.
Export the receive path entry point for the message via ZTESTABLE_STATIC
and add helpers to clear the session state of a test peer and to inject a
message with an arbitrary receiver index.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
When a transport data message arrives for a receiver index that matches
no session, the peer might have a stale session, so we trigger a new
handshake. That path also copied the source address of the message into
the peer endpoint.
That message cannot be authenticated. As the receiver index is unknown,
there is no key to verify it with, so anyone able to send an UDP packet
to our port can craft one: a 16 byte datagram with the transport data
type and an arbitrary receiver index is enough. Because the trigger only
runs when we have neither a handshake nor a current keypair, which is
the state at boot and after the session has expired, a single spoofed
datagram permanently redirects our handshake initiations to an address
of the attacker choosing. The legitimate peer never answers them, so
nothing ever re-authenticates and the endpoint stays poisoned. The
attacker can also relay the initiations to the real peer and place
itself in the middle of the tunnel without being on the path.
Every other endpoint update is done only after the message has been
authenticated, either by the Noise handshake or by an AEAD decrypt
followed by the anti-replay check. Do the same here and never move the
endpoint based on this message. Keep the stale session recovery, but
send the handshake to the endpoint we already trust, falling back to the
configured one if we have not learnt any yet. If neither is known, the
peer can only be reached after it has contacted us with a valid
handshake initiation, so just drop the message.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Fix regression introduced by 069d3a7652. async_read() function
was allocating new buffer even when UART was not expecting it.
Buffer pool was quickly drained and shell was unresponsive.
Added additional check to attempt to allocate new a new buffer
only if UART is waiting for new buffer (UART is disabled or there
is unhandled RX buffer request).
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
The benchmarking framework cannot be used from a C++ translation unit.
C++ requires designated initialisers to appear in declaration order, and
two of the macros do not follow it: struct ztest_benchmark declares run
before teardown while ZTEST_BENCHMARK() initialises teardown first, and
struct ztest_benchmark_timed declares duration_ms before name while
ZTEST_BENCHMARK_TIMED() initialises name first. The two control
benchmarks in the runner have the same problem. C allows any order, so
none of it was noticed.
The header also lacks an extern "C" guard, so the declarations it makes
get C++ linkage and fail to resolve against the framework, which is
compiled as C.
A translation unit that includes the header and instantiates both macros
fails to compile as C++:
benchmark.h: error: designator order for field 'ztest_benchmark::run'
does not match declaration order in 'const ztest_benchmark'
benchmark.h: error: designator order for field
'ztest_benchmark_timed::duration_ms' does not match declaration order
in 'const ztest_benchmark_timed'
Reorder the initialisers to match the structures and wrap the header in
extern "C". No behaviour changes for C.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
dap_connect() discards the return value of swdp_port_on() and answers
DAP_PORT_SWD regardless, so a debug port that failed to come up is
reported to the host as a successful connect. The host then proceeds
into a session in which every transfer fails, with nothing on the wire
explaining why.
The protocol already has the honest answer: the DAP_Connect response
byte is the port that was actually initialized, and DAP_PORT_DISABLED
(0) means the connect failed. Use it.
Also clear DAP_STATE_CONNECTED on the failure path. Without that, the
context believes it is connected while holding nothing: a later
DAP_Disconnect calls swdp_port_off() for a port that was never turned
on, and a retried DAP_Connect returns early on the stale state instead
of attempting the port again.
Co-developed-by: JoaoFelipeBinho <joao@binho.io>
Signed-off-by: Leonardo José Consoni <leonardo@binho.io>
To handle tx from the target, the I2C+GPIO support simulates a
register/address protocol: controller writes one byte (register address)
and reads another (or several) with the contents.
However, a buggy controller may confuse the target as the target keeps
last read register in its own state machine even after the reading was
performed.
This patch makes the controller cleanup its state machine after
receiving an I2C stop, so it's always read for next reading.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
If a buggy controller issues a read request but the target doesn't have
a packet to be read, bail out instead of reading from NULL.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
An off by one bug was present on I2C+GPIO check of packet size. It would
normally not be a problem if the controller respected the protocol and
asked to read only the available bytes. However, a buggy controller
could end up reading one byte more from the buffer containing the
packet.
While at it, ensure that a buggy controller that keeps on reading won't
wrap over the counter (a unint8_t variable) and restart reading the
current packet.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
When the Distributor updates itself, the Firmware Update Server defers
its apply callback until the distribution reaches the Confirm step. The
callback may reboot the device, or call bt_mesh_dfu_srv_applied() and
return. An application that installs the image asynchronously and calls
bt_mesh_dfu_srv_applied() later left the distribution stuck: by then
dfu_confirmed() had returned with the Distribution Phase at Applying
Update, and nothing re-entered it.
Notify a co-located Firmware Distribution Server from
bt_mesh_dfu_srv_applied() so a deferred apply can complete the
distribution without a reboot. dfu_confirmed() skips its own transition
when the notification already completed the distribution, so an apply
that finishes inside the callback still reports Completed once.
Assisted-by: Claude:claude-opus-4.7
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Add a .start model callback to the DFD Server that resumes the
self-update confirm step after reboot. When the DFD Server wakes
up in APPLYING_UPDATE phase (restored from settings), the start
callback:
1. Finds the co-located DFU Server; if it is still in APPLYING
phase, calls bt_mesh_dfu_srv_applied() to transition it to
IDLE so it responds to Firmware Update Information Get with
the new FWID.
2. Calls bt_mesh_dfu_cli_confirm() to resume polling targets
for their updated firmware image.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
When the Distributor is also a DFU target of its own distribution
(self-update), applying the firmware immediately upon receiving the
Update Apply message would reboot the device before it can complete
the confirm step for other targets.
Defer the apply callback on the DFU Server when the Update Start
originated from a local address (self-update detected via
bt_mesh_has_addr). The DFD Server triggers the deferred apply after
the distribution reaches a terminal state (completed or failed).
In the DFU Client confirmed() callback, treat the self-target as
successful even though it hasn't ACKed the Firmware Update Check
message yet — it can't respond because apply was deferred.
Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
The persistence refactoring introduced store_state() calls for the
APPLYING phase, but the error paths in apply_rsp_sent() incorrectly
store state instead of erasing it when transitioning to IDLE:
- When apply prerequisites are missing (no callback or invalid idx),
the phase resets to IDLE but store_state() persists an IDLE phase
that will be rejected on restore. Use erase_state() instead.
- When the application apply callback fails, same issue.
- When handle_cancel() resets the phase to IDLE, the previously
persisted APPLYING state is not erased, causing stale state to
survive across reboots.
Replace store_state() with erase_state() on all paths that transition
to IDLE, and add erase_state() in handle_cancel().
Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Introduce a __packed struct dfu_srv_persistent_state for storing
the DFU Server update state to flash, instead of persisting the
runtime srv->update substruct directly. The store and restore
functions now explicitly marshal/unmarshal each field.
This decouples the on-flash binary layout from the runtime struct,
making it safe to extend or reorder the runtime struct in the future
without breaking previously stored data. The approach matches the
pattern already used by the DFD Server persistence.
The new packed struct is binary-compatible with the existing runtime
layout, so no settings migration is needed.
Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Add bt_mesh_dfu_cli_restore() to put the DFU client into the applied
state with a valid inputs pointer after reboot. Called from
dfd_srv_settings_set() when recovering the Applying Update phase.
This allows bt_mesh_dfu_cli_confirm() to succeed post-reboot, which
is required for the confirm step to poll targets and complete the
distribution.
Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Persist distribution parameters and target list in the DFD Server
when entering the Applying Update phase. Erase persisted state at
terminal phases (Idle, Completed, Failed) to prevent re-triggering
after subsequent reboots. This is the only phase that needs recovery
after reboot for self-update resume.
The slot pointer is resolved in dfd_srv_start() because the slot
settings subtree may load after model settings during initialization.
Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
MshDFUv1.0 Section 6.1.3.6 requires the Firmware Update Server to
respond to a Firmware Update Apply message with status Success and
phase Applying Update when its Update Phase state is Verification
Succeeded or Applying Update (idempotency). The response phase is
always Applying Update in the SUCCESS case.
Section 7.1.2.6 defines the removal rules for the Apply Firmware On
Target Nodes procedure: a Target whose Firmware Update Additional
Information state is not 0x03 (i.e. stays provisioned) that responds
with the Update Phase field set to Applying Update is kept in the
Active Update Receivers state, meaning the Apply step completed
successfully for that Target. The subsequent Refresh Target Nodes
Status procedure (Section 7.1.2.8) is responsible for verifying that
the Target eventually reaches phase Idle.
On the client side, ack any target that answers SUCCESS + APPLYING
during STATE_APPLY, not only the self-target. Previously the response
was dropped without acking the broadcast, so the broadcast retried
Update Apply until timeout and then failed the target with
BT_MESH_DFU_ERR_INTERNAL, wasting ~10 s before the Confirm step could
start. Retrying is also pointless because the Update Apply message is
idempotent (Section 6.1.3.6): further retries cannot change the SUCCESS
+ APPLYING response.
On the server side, split the Firmware Update Status send callback
handling by error type. A start-of-send error (buffer alloc, cancel,
...) means no segments were transmitted; revert the phase to
Verification Succeeded so a client retry is accepted as a fresh apply
per Section 6.1.3.6 "Apply firmware". An end-of-send -ETIMEDOUT means
segments were transmitted but no segment ack was received; a
spec-compliant client that received any complete copy of the SUCCESS
+ APPLYING response has treated it as terminal for the Apply step and
will not retry Update Apply, so proceed with the apply so our state
matches what the client believes. Any other end-of-send error still
reverts the phase. If the client did miss the response and does retry,
the retry hits handle_apply's idempotent APPLYING-phase branch.
Update test_cli_stop's APPLYING case to match: it now expects
BT_MESH_DFU_SUCCESS + PHASE_APPLYING instead of the obsolete
INTERNAL failure outcome.
Assisted-by: Claude:claude-opus-4.7
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
The STM/ESP frontend was checking the log level to decide whether to
include a timestamp on the first FSC packet. In FSC mode, there is no
need to avoid the timestamp to save bytes, since the format supports it.
Always send the timestamp on the first packet to ensure all traced
messages have consistent timestamp data, regardless of the log level.
Signed-off-by: Alejandro Lara Raigada <Alejandro.Lararaigada@analog.com>
hci_num_completed_packets() appends the TX contexts to conn->tx_complete
without any locking, while tx_notify_process() pops them with interrupts
locked. The list is therefore only safe as long as the producer cannot
be preempted by the consumer, which is not something the list itself
guarantees.
Append with the same lock the consumer uses.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
The startup banner made it hard to tell which controller an image is
running against. The line was labelled "Firmware", the fw_variant 0x00
string was the generic "Standard Bluetooth controller", and the only
manufacturer shown was the one on the "HCI: version" line, which is the
Bluetooth company identifier of whoever wrote the controller and reads as
if it identified the stack.
Label the line "Controller" and include the manufacturer on it. Print
"Zephyr Bluetooth Controller" when the controller reports the standard
variant together with The Linux Foundation company identifier, which is
what the Zephyr controller responds with. The meaning of the fw_variant
values is unchanged, since 0x00 is also reported by other conforming
controllers, both in-tree (ESP32) and out of tree. Rename the fw_variant
0x01 string to "Vendor specific Bluetooth Controller" and update the
sample output in the shell documentation to match.
Fixes: #80679
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Assisted-by: Claude:claude-opus-5
Assisted-by: Claude:claude-fable-5
Extend the log_output API with an optional get_available callback that
returns the amount of data currently accepted by the backend.
In dictionary mode, log_dict_output_msg_process() now checks available
space before writing. If the entire message (header + package + data)
cannot fit, the message is dropped atomically rather than being
partially written which corrupts the output stream.
Signed-off-by: Leonardo Bispo <l.bispo@live.com>
Use the configured IPv6 interface count when sizing the mDNS
interface address monitor array. The previous expression used the
IPv4 interface count twice.
Signed-off-by: Carlo Kirchmeier <carlo.kirchmeier.ext@siemens.com>
When no compressed file variant is found, http_compression_text() returns
an empty string. Previously this was unconditionally assigned to
res_detail.content_encoding, causing send_headers_frame() to encode a
content-encoding header with an empty value. HPACK rejects empty header
values, resulting in an HTTP/2 protocol error on the client.
Guard the assignment so content_encoding is only set when a compression
algorithm was actually selected.
Signed-off-by: Martin Koloska <martin.koloska@bytesatwork.ch>
An MCUmgr image upload over the shell transport hard faults the device.
Not an error return, not a dropped frame - a fault in the shell_uart
thread, then a watchdog reset. It looks like a silent transport, because
by the time a host retries anything the board has rebooted and answers
normally.
mcumgr_serial_process_frag reads the two framing bytes of every line as
op = sys_be16_to_cpu(*(uint16_t *)frag);
frag points into a net_buf from the shell transport's pool, and that pool
is defined in subsys/shell/backends/shell_uart.c with a data size of
SMP_SHELL_RX_BUF_SIZE, which is 127. NET_BUF_POOL_FIXED_DEFINE aligns the
array but strides its rows by the data size, so with an odd stride every
other buffer in the pool starts on an odd address. The cast is then an
unaligned 16-bit load.
ARMv7-M fixes those up in hardware, which is why this has gone unnoticed:
on a Cortex-M3, M4 or M33 the code is merely undefined behaviour that
happens to work. ARMv8-M Baseline does not. On a Cortex-M23 it is a
HardFault.
That is also why the failure looks selective rather than total. A request
that fits one framing line uses the first buffer in the pool, which is
aligned, and is answered: image state read works every time. A request
spanning two or more lines reaches the second buffer and faults. An image
upload cannot fit one line, because its first request carries image, len,
off and a 32-byte sha before any image data, so upload never works and
everything else does.
sys_get_be16() is the alignment-safe read and is what the rest of the
tree uses for exactly this. The fix does not depend on the buffer size,
which is the other half of the story: SMP_SHELL_RX_BUF_SIZE is a
hardcoded macro rather than a Kconfig symbol, so no application can round
the stride up to avoid this.
Found on a Microchip PIC32CM5112GC00100 (Cortex-M23). The faulting PC
resolves to serial_util.c:161, called from smp_shell_process at
smp_shell.c:213, in thread shell_uart.
Signed-off-by: Arkadiusz Grzelka <devitwise@gmail.com>
Allocating a packet together with its buffer took a deadline on entry
and worked out the remaining time again after the packet itself had been
taken from the slab, so that the buffer allocation got what was left of
the caller's timeout. Both of those read the clock, and neither is
needed when the slab had a free entry, which is the normal case.
Take the packet without waiting first. When that works no time has
passed, so the caller's timeout can be passed on to the buffer
allocation as it stands. Only when the slab is empty is a deadline taken
and the remainder worked out afterwards, and it is now taken immediately
before the one call that can wait.
Callers that asked not to wait at all still make exactly one attempt.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Building a packet's buffer chain allocates one net_buf per fragment, and
every one of them read the clock three times: once at the bottom of the
loop here, and twice more inside net_buf_alloc_len(), which takes a
deadline on entry and works out the remaining time again before
allocating the data. Each read goes through sys_clock_tick_get() to the
timer driver, and on a target whose timer frequency is only known at
runtime that is a 64-bit software divide as well.
With the default 128 byte fragments a 1280 byte frame is ten fragments,
so a single packet paid for about thirty of them. On a QEMU icount
profile of a zperf TCP loopback run the four functions involved,
sys_clock_elapsed, sys_timepoint_timeout, __udivdi3 and
sys_timepoint_calc, came to 12.0 instructions per payload byte, 19% of
the run. UDP measured the same proportion, so this is not specific to
either protocol.
None of that work is needed. An allocation that does not block cannot
have consumed any of the caller's timeout, so ask the pool without
waiting first and only work out how much time is left when the pool
turns out to be empty. Passing K_NO_WAIT also makes the deadline
handling inside net_buf_alloc_len() short circuit, so one change here
removes all three reads rather than one.
The deadline itself is unchanged: it is still taken on entry, and every
allocation that does wait is still measured against that same instant,
so an allocation cannot take longer than it did before. Callers that
asked not to wait at all are unaffected, they still make exactly one
attempt.
The one visible difference is that with CONFIG_NET_BUF_LOG enabled a
fragment that has to wait now also logs the failed attempt that preceded
the wait.
The blocking path had no test coverage at all, every allocation in the
net_pkt tests asked not to wait, so add four. The one that matters
checks that the timeout is a budget for the whole chain rather than for
each fragment of it: with a buffer handed back every 60 ms, a three
fragment allocation given 100 ms must give up instead of collecting all
three.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Remove stream_flash_erase_page(), deprecated in Zephyr 4.1. There is no
Stream Flash replacement by design; callers needing an explicit erase
should use flash_area_erase() or flash_erase() directly.
The ctx->erased_up_to field is kept: it is still used by the progressive
erase performed from stream_flash_buffered_write().
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5
Remove CONFIG_MCUMGR_GRP_OS_INFO_HARDWARE_INFO_SHORT_HARDWARE_PLATFORM,
which was introduced already deprecated in Zephyr 4.3 as an opt-in back
to the pre-4.3 hardware platform output of the os_mgmt info command.
The info command now unconditionally reports CONFIG_BOARD_TARGET, which
includes the SoC and board variant. Builds that had opted back into the
board and board revision format see their SMP info response text change,
as announced by the 4.3 deprecation.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5
Remove CONFIG_MCUBOOT_BOOTLOADER_MODE_SWAP_WITHOUT_SCRATCH, deprecated in
Zephyr 4.1 in favour of CONFIG_MCUBOOT_BOOTLOADER_MODE_SWAP_USING_MOVE,
which selects the same MCUBOOT_BOOTLOADER_MODE_HAS_NO_DOWNGRADE and maps
to the same MCUBOOT_MODE_SWAP_USING_MOVE bootloader info value.
The MCUmgr img_mgmt and os_mgmt users only ever OR'd the deprecated
symbol with its replacement, so dropping the disjunct is behaviour
preserving. The sysbuild counterpart was already removed.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5
The SDP client allocates the receive buffer from the application
provided pool with K_FOREVER, in sdp_client_discover() while holding
the session lock, and in the L2CAP alloc_buf callback which
sdp_client_connected() also calls with the lock held.
Both run in the Bluetooth workqueue, which is the same context that
releases these buffers once a discovery completes, so waiting for a
buffer there cannot make progress. It also blocks any other user of the
session for as long as the pool stays empty.
Allocate without waiting. Both call sites already handle the allocation
failure by disconnecting the SDP channel, and the L2CAP layer handles
alloc_buf() returning NULL, so the assert on the returned buffer is
dropped.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
num_phys was used to size the command buffer, and became dead when
commit 2ea9605380 ("Bluetooth: Host: core: Use bt_hci_cmd_alloc()")
made the buffer be allocated without a length.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Same as the previous commit, for the remaining variables in conn.c and
l2cap.c that are only ever read by an __ASSERT().
Assisted-by: Claude:claude-opus-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
These variables exist only to be checked by __ASSERT_NO_MSG(), which
compiles out when CONFIG_ASSERT is disabled, leaving them set but never
read. GCC builds do not show this since Zephyr passes
-Wno-unused-but-set-variable, but clang and arcmwdt enable the warning
at warning level 1.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
bt_smp_le_oob_generate_sc_data() returns directly when k_condvar_wait()
times out, without unlocking pub_key_gen.lock. k_condvar_wait()
re-acquires the mutex before returning, on timeout as well as on
signal, so the mutex is left locked forever.
Any subsequent public key generation callback then blocks whichever
context runs it indefinitely, since pub_key_ready_notify() takes the
same mutex with K_FOREVER.
Unlock the mutex before returning on the timeout path.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Check the size with CHECKIF() and return NULL when the control block is
undersized, which is also what the CMSIS-RTOS2 contract expects.
Signed-off-by: Flavio Ceolin <flavio@hubble.com>
Check the size with CHECKIF() and return NULL when the control block is
undersized, which is also what the CMSIS-RTOS2 contract expects.
Signed-off-by: Flavio Ceolin <flavio@hubble.com>
Check the size with CHECKIF() and return NULL when the control block is
undersized, which is also what the CMSIS-RTOS2 contract expects.
Signed-off-by: Flavio Ceolin <flavio@hubble.com>