mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-06-20 08:18:35 +02:00
device: fix potential null dereference when releasing port
find_port_info() can return NULL if the port is not registered.
The code dereferenced `info->port_state` before the null check,
which would crash. Move the null check before the dereference.
Found by Coverity (CID: REVERSE_INULL).
Fixes: a8329587c8 ('device: fix bug when deactivating port connections asynchronously')
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
4565c9efe4
commit
56099c5e14
1 changed files with 4 additions and 2 deletions
|
|
@ -7234,7 +7234,9 @@ nm_device_controller_release_port(NMDevice *self,
|
|||
|
||||
info = find_port_info(self, port);
|
||||
|
||||
if (info->port_state == PORT_STATE_ATTACHED)
|
||||
if (!info)
|
||||
port_state_str = "(not registered)";
|
||||
else if (info->port_state == PORT_STATE_ATTACHED)
|
||||
port_state_str = "(attached)";
|
||||
else if (info->port_state == PORT_STATE_NOT_ATTACHED)
|
||||
port_state_str = "(not attached)";
|
||||
|
|
@ -7247,7 +7249,7 @@ nm_device_controller_release_port(NMDevice *self,
|
|||
"controller: release one port " NM_HASH_OBFUSCATE_PTR_FMT "/%s %s%s",
|
||||
NM_HASH_OBFUSCATE_PTR(port),
|
||||
nm_device_get_iface(port),
|
||||
!info ? "(not registered)" : port_state_str,
|
||||
port_state_str,
|
||||
release_type == RELEASE_PORT_TYPE_CONFIG_FORCE
|
||||
? " (force-configure)"
|
||||
: (release_type == RELEASE_PORT_TYPE_CONFIG ? " (configure)" : "(no-config)"));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue