Commit b9ff5bc5 authored by Ralf Bächle's avatar Ralf Bächle

Protect listen_list also with a spinlock instead of cli / sti.

parent 3652c0a0
...@@ -10,7 +10,5 @@ af_ax25.c:ax25_connect: ...@@ -10,7 +10,5 @@ af_ax25.c:ax25_connect:
} }
Do the ax25_list_lock, ax25_uid_lock, ax25_route_lock, protocol_list_lock, Do the ax25_list_lock, ax25_uid_lock, ax25_route_lock, protocol_list_lock,
ax25_dev_lock, linkfail_lockreally and ax25_frag_lock have to be interrupt ax25_dev_lock, linkfail_lockreally, ax25_frag_lock and listen_lock have to
safe? be interrupt safe?
What locking will be needed for listen_list?
...@@ -54,6 +54,7 @@ static struct listen_struct { ...@@ -54,6 +54,7 @@ static struct listen_struct {
ax25_address callsign; ax25_address callsign;
struct net_device *dev; struct net_device *dev;
} *listen_list; } *listen_list;
static spinlock_t listen_lock = SPIN_LOCK_UNLOCKED;
int ax25_protocol_register(unsigned int pid, int (*func)(struct sk_buff *, ax25_cb *)) int ax25_protocol_register(unsigned int pid, int (*func)(struct sk_buff *, ax25_cb *))
{ {
...@@ -176,31 +177,27 @@ int ax25_listen_register(ax25_address *callsign, struct net_device *dev) ...@@ -176,31 +177,27 @@ int ax25_listen_register(ax25_address *callsign, struct net_device *dev)
listen->callsign = *callsign; listen->callsign = *callsign;
listen->dev = dev; listen->dev = dev;
save_flags(flags); spin_lock_irqsave(&listen_lock, flags);
cli();
listen->next = listen_list; listen->next = listen_list;
listen_list = listen; listen_list = listen;
spin_unlock_irqrestore(&listen_lock, flags);
restore_flags(flags);
return 1; return 1;
} }
void ax25_listen_release(ax25_address *callsign, struct net_device *dev) void ax25_listen_release(ax25_address *callsign, struct net_device *dev)
{ {
struct listen_struct *s, *listen = listen_list; struct listen_struct *s, *listen;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&listen_lock, flags);
listen = listen_list;
if (listen == NULL) if (listen == NULL)
return; return;
save_flags(flags);
cli();
if (ax25cmp(&listen->callsign, callsign) == 0 && listen->dev == dev) { if (ax25cmp(&listen->callsign, callsign) == 0 && listen->dev == dev) {
listen_list = listen->next; listen_list = listen->next;
restore_flags(flags); spin_unlock_irqrestore(&listen_lock, flags);
kfree(listen); kfree(listen);
return; return;
} }
...@@ -209,15 +206,14 @@ void ax25_listen_release(ax25_address *callsign, struct net_device *dev) ...@@ -209,15 +206,14 @@ void ax25_listen_release(ax25_address *callsign, struct net_device *dev)
if (ax25cmp(&listen->next->callsign, callsign) == 0 && listen->next->dev == dev) { if (ax25cmp(&listen->next->callsign, callsign) == 0 && listen->next->dev == dev) {
s = listen->next; s = listen->next;
listen->next = listen->next->next; listen->next = listen->next->next;
restore_flags(flags); spin_unlock_irqrestore(&listen_lock, flags);
kfree(s); kfree(s);
return; return;
} }
listen = listen->next; listen = listen->next;
} }
spin_unlock_irqrestore(&listen_lock, flags);
restore_flags(flags);
} }
int (*ax25_protocol_function(unsigned int pid))(struct sk_buff *, ax25_cb *) int (*ax25_protocol_function(unsigned int pid))(struct sk_buff *, ax25_cb *)
...@@ -240,10 +236,13 @@ int (*ax25_protocol_function(unsigned int pid))(struct sk_buff *, ax25_cb *) ...@@ -240,10 +236,13 @@ int (*ax25_protocol_function(unsigned int pid))(struct sk_buff *, ax25_cb *)
int ax25_listen_mine(ax25_address *callsign, struct net_device *dev) int ax25_listen_mine(ax25_address *callsign, struct net_device *dev)
{ {
struct listen_struct *listen; struct listen_struct *listen;
unsigned long flags;
spin_lock_irqsave(&listen_lock, flags);
for (listen = listen_list; listen != NULL; listen = listen->next) for (listen = listen_list; listen != NULL; listen = listen->next)
if (ax25cmp(&listen->callsign, callsign) == 0 && (listen->dev == dev || listen->dev == NULL)) if (ax25cmp(&listen->callsign, callsign) == 0 && (listen->dev == dev || listen->dev == NULL))
return 1; return 1;
spin_unlock_irqrestore(&listen_lock, flags);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment