]> www.infradead.org Git - users/willy/xarray.git/commit
netpoll: Ensure clean state on setup failures
authorBreno Leitao <leitao@debian.org>
Thu, 22 Aug 2024 11:10:47 +0000 (04:10 -0700)
committerJakub Kicinski <kuba@kernel.org>
Mon, 26 Aug 2024 16:25:44 +0000 (09:25 -0700)
commitae5a0456e0b4cfd7e61619e55251ffdf1bc7adfb
treef6ffe56e12f7d3b4579f858fa7f63d9af872d99a
parentf086d18db11724f55e70e001ce5cc29fdf47bb55
netpoll: Ensure clean state on setup failures

Modify netpoll_setup() and __netpoll_setup() to ensure that the netpoll
structure (np) is left in a clean state if setup fails for any reason.
This prevents carrying over misconfigured fields in case of partial
setup success.

Key changes:
- np->dev is now set only after successful setup, ensuring it's always
  NULL if netpoll is not configured or if netpoll_setup() fails.
- np->local_ip is zeroed if netpoll setup doesn't complete successfully.
- Added DEBUG_NET_WARN_ON_ONCE() checks to catch unexpected states.
- Reordered some operations in __netpoll_setup() for better logical flow.

These changes improve the reliability of netpoll configuration, since it
assures that the structure is fully initialized or totally unset.

Suggested-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Breno Leitao <leitao@debian.org>
Link: https://patch.msgid.link/20240822111051.179850-2-leitao@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/netpoll.c