Commit fb1f23ea authored by Geliang Tang's avatar Geliang Tang Committed by Antonio Quartulli

batman-adv: use list_for_each_entry_safe

Use list_for_each_entry_safe() instead of list_for_each_safe() to
simplify the code.
Signed-off-by: default avatarGeliang Tang <geliangtang@163.com>
Acked-by: default avatarAntonio Quartulli <a@unstable.cc>
Reviewed-by: default avatarSven Eckelmann <sven@narfation.org>
Signed-off-by: default avatarMarek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: default avatarAntonio Quartulli <a@unstable.cc>
parent 925a6f37
...@@ -104,25 +104,21 @@ static int batadv_socket_open(struct inode *inode, struct file *file) ...@@ -104,25 +104,21 @@ static int batadv_socket_open(struct inode *inode, struct file *file)
static int batadv_socket_release(struct inode *inode, struct file *file) static int batadv_socket_release(struct inode *inode, struct file *file)
{ {
struct batadv_socket_client *socket_client = file->private_data; struct batadv_socket_client *client = file->private_data;
struct batadv_socket_packet *socket_packet; struct batadv_socket_packet *packet, *tmp;
struct list_head *list_pos, *list_pos_tmp;
spin_lock_bh(&socket_client->lock); spin_lock_bh(&client->lock);
/* for all packets in the queue ... */ /* for all packets in the queue ... */
list_for_each_safe(list_pos, list_pos_tmp, &socket_client->queue_list) { list_for_each_entry_safe(packet, tmp, &client->queue_list, list) {
socket_packet = list_entry(list_pos, list_del(&packet->list);
struct batadv_socket_packet, list); kfree(packet);
list_del(list_pos);
kfree(socket_packet);
} }
batadv_socket_client_hash[socket_client->index] = NULL; batadv_socket_client_hash[client->index] = NULL;
spin_unlock_bh(&socket_client->lock); spin_unlock_bh(&client->lock);
kfree(socket_client); kfree(client);
module_put(THIS_MODULE); module_put(THIS_MODULE);
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