[FIX] Add spinlock for proc_list in pf_group 46/46846/4
authorVyacheslav Cherkashin <v.cherkashin@samsung.com>
Thu, 20 Aug 2015 16:44:27 +0000 (19:44 +0300)
committerDmitry Kovalenko <d.kovalenko@samsung.com>
Fri, 28 Aug 2015 06:02:08 +0000 (23:02 -0700)
Change-Id: Iaaafc4dd4665dbc1e06c280cdc6e7036122f8678
Signed-off-by: Vyacheslav Cherkashin <v.cherkashin@samsung.com>
us_manager/pf/pf_group.c

index f91a5c6..28b232a 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/list.h>
 #include <linux/namei.h>
 #include <linux/mman.h>
+#include <linux/spinlock.h>
 #include "pf_group.h"
 #include "proc_filters.h"
 #include "../sspt/sspt_filter.h"
@@ -45,7 +46,7 @@ struct pf_group {
        struct pfg_msg_cb *msg_cb;
        atomic_t usage;
 
-       /* TODO: proc_list*/
+       spinlock_t pl_lock;     /* for proc_list */
        struct list_head proc_list;
 };
 
@@ -113,6 +114,7 @@ static struct pf_group *create_pfg(void)
 
        INIT_LIST_HEAD(&pfg->list);
        memset(&pfg->filter, 0, sizeof(pfg->filter));
+       spin_lock_init(&pfg->pl_lock);
        INIT_LIST_HEAD(&pfg->proc_list);
        pfg->msg_cb = NULL;
        atomic_set(&pfg->usage, 1);
@@ -467,7 +469,9 @@ static int pfg_add_proc(struct pf_group *pfg, struct sspt_proc *proc)
        if (pls == NULL)
                return -ENOMEM;
 
+       spin_lock(&pfg->pl_lock);
        add_pl_struct(pfg, pls);
+       spin_unlock(&pfg->pl_lock);
 
        return 0;
 }
@@ -590,11 +594,13 @@ void uninstall_proc(struct sspt_proc *proc)
 
        read_lock(&pfg_list_lock);
        list_for_each_entry(pfg, &pfg_list, list) {
+               spin_lock(&pfg->pl_lock);
                pls = find_pl_struct(pfg, task);
                if (pls) {
                        del_pl_struct(pls);
                        free_pl_struct(pls);
                }
+               spin_unlock(&pfg->pl_lock);
        }
        read_unlock(&pfg_list_lock);