Skip to content

Commit

Permalink
net: hsr: prevent NULL pointer dereference in hsr_proxy_announce()
Browse files Browse the repository at this point in the history
[ Upstream commit a7789fd ]

In the function hsr_proxy_annouance() added in the previous commit
5f703ce ("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.

To solve this, we need to add code to check whether the return value
of hsr_port_get_hsr() is NULL.

Reported-by: [email protected]
Fixes: 5f703ce ("net: hsr: Send supervisory frames to HSR network with ProxyNodeTable data")
Signed-off-by: Jeongjun Park <[email protected]>
Reviewed-by: Simon Horman <[email protected]>
Acked-by: Lukasz Majewski <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
name2965 authored and gregkh committed Sep 18, 2024
1 parent 1f68e09 commit 8d0c336
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions net/hsr/hsr_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,9 @@ static void hsr_proxy_announce(struct timer_list *t)
* of SAN nodes stored in ProxyNodeTable.
*/
interlink = hsr_port_get_hsr(hsr, HSR_PT_INTERLINK);
if (!interlink)
goto done;

list_for_each_entry_rcu(node, &hsr->proxy_node_db, mac_list) {
if (hsr_addr_is_redbox(hsr, node->macaddress_A))
continue;
Expand All @@ -441,6 +444,7 @@ static void hsr_proxy_announce(struct timer_list *t)
mod_timer(&hsr->announce_proxy_timer, jiffies + interval);
}

done:
rcu_read_unlock();
}

Expand Down

0 comments on commit 8d0c336

Please sign in to comment.