Subject: Re: [PATCH net] net: hsr: prevent NULL pointer dereference in hsr_proxy_announce()

From: Jakub Kicinski <[email-masked]>
Date: Tue, 10 Sep 2024 19:15:17 -0700

On Mon, 9 Sep 2024 10:58:22 +0200 Lukasz Majewski wrote:
> > In the function hsr_proxy_annouance() added in the previous commit 
> > 5f703ce5c981 ("net: hsr: Send supervisory frames to HSR network 
> > with ProxyNodeTable data"), the return value of the
> > hsr_port_get_hsr() function is not checked to be a NULL pointer,
> > which causes a NULL pointer dereference.  
> 
> Thank you for your patch.
> 
> The code in hsr_proxy_announcement() is _only_ executed (the timer is
> configured to trigger this function) when hsr->redbox is set, which
> means that somebody has called earlier iproute2 command:
> 
> ip link add name hsr1 type hsr slave1 lan4 slave2 lan5 interlink lan3
> supervision 45 version 1

Are you trying to say the patch is correct or incorrect?
The structs have no refcounting - should the timers be deleted with
_sync() inside hsr_check_announce()?