• Breno Leitao's avatar
    netpoll: Ensure clean state on setup failures · ae5a0456
    Breno Leitao authored
    
    
    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: default avatarPaolo Abeni <pabeni@redhat.com>
    Signed-off-by: default avatarBreno Leitao <leitao@debian.org>
    Link: https://patch.msgid.link/20240822111051.179850-2-leitao@debian.org
    
    Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
    ae5a0456
netpoll.c 19.5 KB