Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[deliverable/linux.git] / net / tipc / port.c
index 99846a18d94e19b46301a6cef57c057802a3e818..b7f3199523caaf846d0aa1479c69888426374040 100644 (file)
@@ -57,8 +57,8 @@
 static struct sk_buff *msg_queue_head = NULL;
 static struct sk_buff *msg_queue_tail = NULL;
 
-spinlock_t tipc_port_list_lock = SPIN_LOCK_UNLOCKED;
-static spinlock_t queue_lock = SPIN_LOCK_UNLOCKED;
+DEFINE_SPINLOCK(tipc_port_list_lock);
+static DEFINE_SPINLOCK(queue_lock);
 
 static LIST_HEAD(ports);
 static void port_handle_node_down(unsigned long ref);
@@ -168,7 +168,6 @@ void tipc_port_recv_mcast(struct sk_buff *buf, struct port_list *dp)
        struct port_list *item = dp;
        int cnt = 0;
 
-       assert(buf);
        msg = buf_msg(buf);
 
        /* Create destination port list, if one wasn't supplied */
@@ -196,7 +195,7 @@ void tipc_port_recv_mcast(struct sk_buff *buf, struct port_list *dp)
                        struct sk_buff *b = skb_clone(buf, GFP_ATOMIC);
 
                        if (b == NULL) {
-                               warn("Buffer allocation failure\n");
+                               warn("Unable to deliver multicast message(s)\n");
                                msg_dbg(msg, "LOST:");
                                goto exit;
                        }
@@ -227,15 +226,14 @@ u32 tipc_createport_raw(void *usr_handle,
        struct tipc_msg *msg;
        u32 ref;
 
-       p_ptr = kmalloc(sizeof(*p_ptr), GFP_ATOMIC);
-       if (p_ptr == NULL) {
-               warn("Memory squeeze; failed to create port\n");
+       p_ptr = kzalloc(sizeof(*p_ptr), GFP_ATOMIC);
+       if (!p_ptr) {
+               warn("Port creation failed, no memory\n");
                return 0;
        }
-       memset(p_ptr, 0, sizeof(*p_ptr));
        ref = tipc_ref_acquire(p_ptr, &p_ptr->publ.lock);
        if (!ref) {
-               warn("Reference Table Exhausted\n");
+               warn("Port creation failed, reference table exhausted\n");
                kfree(p_ptr);
                return 0;
        }
@@ -507,9 +505,14 @@ static void port_timeout(unsigned long ref)
        struct port *p_ptr = tipc_port_lock(ref);
        struct sk_buff *buf = NULL;
 
-       if (!p_ptr || !p_ptr->publ.connected)
+       if (!p_ptr)
                return;
 
+       if (!p_ptr->publ.connected) {
+               tipc_port_unlock(p_ptr);
+               return;
+       }
+
        /* Last probe answered ? */
        if (p_ptr->probing_state == PROBING) {
                buf = port_build_self_abort_msg(p_ptr, TIPC_ERR_NO_PORT);
@@ -1059,8 +1062,8 @@ int tipc_createport(u32 user_ref,
        struct port *p_ptr; 
        u32 ref;
 
-       up_ptr = (struct user_port *)kmalloc(sizeof(*up_ptr), GFP_ATOMIC);
-       if (up_ptr == NULL) {
+       up_ptr = kmalloc(sizeof(*up_ptr), GFP_ATOMIC);
+       if (!up_ptr) {
                warn("Port creation failed, no memory\n");
                return -ENOMEM;
        }
@@ -1133,11 +1136,12 @@ int tipc_publish(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
        int res = -EINVAL;
 
        p_ptr = tipc_port_lock(ref);
+       if (!p_ptr)
+               return -EINVAL;
+
        dbg("tipc_publ %u, p_ptr = %x, conn = %x, scope = %x, "
            "lower = %u, upper = %u\n",
            ref, p_ptr, p_ptr->publ.connected, scope, seq->lower, seq->upper);
-       if (!p_ptr)
-               return -EINVAL;
        if (p_ptr->publ.connected)
                goto exit;
        if (seq->lower > seq->upper)
This page took 0.047635 seconds and 5 git commands to generate.