]> err.no Git - linux-2.6/blobdiff - drivers/scsi/scsi_transport_iscsi.c
[SCSI] iscsi: data under/over flow fix
[linux-2.6] / drivers / scsi / scsi_transport_iscsi.c
index e4fceca49e564d09165c141deee3f843ef2aed99..50ed88f98f4678063243983576d64b3c158f9f82 100644 (file)
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 #include <linux/module.h>
+#include <linux/string.h>
+#include <linux/slab.h>
 #include <linux/mempool.h>
+#include <linux/mutex.h>
 #include <net/tcp.h>
+
 #include <scsi/scsi.h>
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_device.h>
@@ -43,7 +47,7 @@ struct iscsi_internal {
        struct list_head sessions;
        /*
         * lock to serialize access to the sessions list which must
-        * be taken after the rx_queue_sema
+        * be taken after the rx_queue_mutex
         */
        spinlock_t session_lock;
        /*
@@ -67,7 +71,7 @@ struct iscsi_internal {
 /*
  * list of registered transports and lock that must
  * be held while accessing list. The iscsi_transport_lock must
- * be acquired after the rx_queue_sema.
+ * be acquired after the rx_queue_mutex.
  */
 static LIST_HEAD(iscsi_transports);
 static DEFINE_SPINLOCK(iscsi_transport_lock);
@@ -97,7 +101,7 @@ static ssize_t
 show_transport_handle(struct class_device *cdev, char *buf)
 {
        struct iscsi_internal *priv = cdev_to_iscsi_internal(cdev);
-       return sprintf(buf, "%llu", (unsigned long long)iscsi_handle(priv->iscsi_transport));
+       return sprintf(buf, "%llu\n", (unsigned long long)iscsi_handle(priv->iscsi_transport));
 }
 static CLASS_DEVICE_ATTR(handle, S_IRUGO, show_transport_handle, NULL);
 
@@ -142,7 +146,7 @@ static DECLARE_TRANSPORT_CLASS(iscsi_connection_class,
 
 static struct sock *nls;
 static int daemon_pid;
-static DECLARE_MUTEX(rx_queue_sema);
+static DEFINE_MUTEX(rx_queue_mutex);
 
 struct mempool_zone {
        mempool_t *pool;
@@ -246,7 +250,7 @@ static inline struct list_head *skb_to_lh(struct sk_buff *skb)
 }
 
 static void*
-mempool_zone_alloc_skb(unsigned int gfp_mask, void *pool_data)
+mempool_zone_alloc_skb(gfp_t gfp_mask, void *pool_data)
 {
        struct mempool_zone *zone = pool_data;
 
@@ -878,7 +882,7 @@ iscsi_if_rx(struct sock *sk, int len)
 {
        struct sk_buff *skb;
 
-       down(&rx_queue_sema);
+       mutex_lock(&rx_queue_mutex);
        while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) {
                while (skb->len >= NLMSG_SPACE(0)) {
                        int err;
@@ -920,7 +924,7 @@ iscsi_if_rx(struct sock *sk, int len)
                }
                kfree_skb(skb);
        }
-       up(&rx_queue_sema);
+       mutex_unlock(&rx_queue_mutex);
 }
 
 /*
@@ -1156,7 +1160,7 @@ int iscsi_unregister_transport(struct iscsi_transport *tt)
 
        BUG_ON(!tt);
 
-       down(&rx_queue_sema);
+       mutex_lock(&rx_queue_mutex);
 
        priv = iscsi_if_transport_lookup(tt);
        BUG_ON (!priv);
@@ -1164,7 +1168,7 @@ int iscsi_unregister_transport(struct iscsi_transport *tt)
        spin_lock_irqsave(&priv->session_lock, flags);
        if (!list_empty(&priv->sessions)) {
                spin_unlock_irqrestore(&priv->session_lock, flags);
-               up(&rx_queue_sema);
+               mutex_unlock(&rx_queue_mutex);
                return -EPERM;
        }
        spin_unlock_irqrestore(&priv->session_lock, flags);
@@ -1178,7 +1182,7 @@ int iscsi_unregister_transport(struct iscsi_transport *tt)
 
        sysfs_remove_group(&priv->cdev.kobj, &iscsi_transport_group);
        class_device_unregister(&priv->cdev);
-       up(&rx_queue_sema);
+       mutex_unlock(&rx_queue_mutex);
 
        return 0;
 }