mirror of
https://kernel.googlesource.com/pub/scm/linux/kernel/git/stable/linux-stable.git
synced 2025-09-25 16:49:33 +10:00
net: rose: split remove and free operations in rose_remove_neigh()
The current rose_remove_neigh() performs two distinct operations: 1. Removes rose_neigh from rose_neigh_list 2. Frees the rose_neigh structure Split these operations into separate functions to improve maintainability and prepare for upcoming refcount_t conversion. The timer cleanup remains in rose_remove_neigh() because free operations can be called from timer itself. This patch introduce rose_neigh_put() to handle the freeing of rose_neigh structures and modify rose_remove_neigh() to handle removal only. Signed-off-by: Takamitsu Iwai <takamitz@amazon.co.jp> Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com> Link: https://patch.msgid.link/20250823085857.47674-2-takamitz@amazon.co.jp Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
9448ccd853
commit
dcb3465902
@ -151,6 +151,14 @@ struct rose_sock {
|
||||
|
||||
#define rose_sk(sk) ((struct rose_sock *)(sk))
|
||||
|
||||
static inline void rose_neigh_put(struct rose_neigh *rose_neigh)
|
||||
{
|
||||
if (rose_neigh->ax25)
|
||||
ax25_cb_put(rose_neigh->ax25);
|
||||
kfree(rose_neigh->digipeat);
|
||||
kfree(rose_neigh);
|
||||
}
|
||||
|
||||
/* af_rose.c */
|
||||
extern ax25_address rose_callsign;
|
||||
extern int sysctl_rose_restart_request_timeout;
|
||||
|
@ -234,20 +234,12 @@ static void rose_remove_neigh(struct rose_neigh *rose_neigh)
|
||||
|
||||
if ((s = rose_neigh_list) == rose_neigh) {
|
||||
rose_neigh_list = rose_neigh->next;
|
||||
if (rose_neigh->ax25)
|
||||
ax25_cb_put(rose_neigh->ax25);
|
||||
kfree(rose_neigh->digipeat);
|
||||
kfree(rose_neigh);
|
||||
return;
|
||||
}
|
||||
|
||||
while (s != NULL && s->next != NULL) {
|
||||
if (s->next == rose_neigh) {
|
||||
s->next = rose_neigh->next;
|
||||
if (rose_neigh->ax25)
|
||||
ax25_cb_put(rose_neigh->ax25);
|
||||
kfree(rose_neigh->digipeat);
|
||||
kfree(rose_neigh);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -331,8 +323,10 @@ static int rose_del_node(struct rose_route_struct *rose_route,
|
||||
if (rose_node->neighbour[i] == rose_neigh) {
|
||||
rose_neigh->count--;
|
||||
|
||||
if (rose_neigh->count == 0 && rose_neigh->use == 0)
|
||||
if (rose_neigh->count == 0 && rose_neigh->use == 0) {
|
||||
rose_remove_neigh(rose_neigh);
|
||||
rose_neigh_put(rose_neigh);
|
||||
}
|
||||
|
||||
rose_node->count--;
|
||||
|
||||
@ -513,6 +507,7 @@ void rose_rt_device_down(struct net_device *dev)
|
||||
}
|
||||
|
||||
rose_remove_neigh(s);
|
||||
rose_neigh_put(s);
|
||||
}
|
||||
spin_unlock_bh(&rose_neigh_list_lock);
|
||||
spin_unlock_bh(&rose_node_list_lock);
|
||||
@ -569,6 +564,7 @@ static int rose_clear_routes(void)
|
||||
if (s->use == 0 && !s->loopback) {
|
||||
s->count = 0;
|
||||
rose_remove_neigh(s);
|
||||
rose_neigh_put(s);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1301,6 +1297,7 @@ void __exit rose_rt_free(void)
|
||||
rose_neigh = rose_neigh->next;
|
||||
|
||||
rose_remove_neigh(s);
|
||||
rose_neigh_put(s);
|
||||
}
|
||||
|
||||
while (rose_node != NULL) {
|
||||
|
Loading…
Reference in New Issue
Block a user