]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
qla2xxx: Correct loop_id_map allocation-size and usage.
authorAndrew Vasquez <andrew.vasquez@qlogic.com>
Fri, 31 Aug 2012 04:54:20 +0000 (21:54 -0700)
committerMaxim Uvarov <maxim.uvarov@oracle.com>
Mon, 3 Sep 2012 08:34:40 +0000 (01:34 -0700)
Bugdb: 13653
Original code incorrectly assigned LOOPID_MAP_SIZE to be the
allocation size in bytes rather than total bit size.
Additionally corrected code to check for bit-allocation failure
in qla2x00_find_new_loop_id().

JIRA Key: V2632FC-270

drivers/scsi/qla2xxx/qla_def.h
drivers/scsi/qla2xxx/qla_init.c
drivers/scsi/qla2xxx/qla_os.c

index 2cde41ce591b7b2da5d9ccb24f5cc757166dc140..faac561b0ca18383e675850cd1fb0c572c935d7d 100644 (file)
 #define MAX_FIBRE_DEVICES_2400 2048
 #define MAX_FIBRE_DEVICES_LOOP 128
 #define MAX_FIBRE_DEVICES_MAX  MAX_FIBRE_DEVICES_2400
-#define LOOPID_MAP_SIZE                (ha->max_fibre_devices / 8)
+#define LOOPID_MAP_SIZE                (ha->max_fibre_devices)
 #define MAX_FIBRE_LUNS         0xFFFF
 #define        MAX_HOST_COUNT          16
 
index eeeba5e9f784dfa13a4f2ac961ec68875b29e09a..bd8e691e51e5bcb4ad6c6b780664a40421d6e168 100644 (file)
@@ -3410,8 +3410,8 @@ qla2x00_find_new_loop_id(scsi_qla_host_t *vha, fc_port_t *dev)
 
        dev->loop_id = find_first_zero_bit(ha->loop_id_map,
            LOOPID_MAP_SIZE);
-
-       if (qla2x00_is_reserved_id(vha, dev->loop_id)) {
+       if (dev->loop_id >= LOOPID_MAP_SIZE ||
+           qla2x00_is_reserved_id(vha, dev->loop_id)) {
                dev->loop_id = FC_NO_LOOP_ID;
                rval = QLA_FUNCTION_FAILED;
        } else
index d17917c019374439de174d10392e9e5ff46b0a5d..aa8a15e03b70cd2cf49b389b8f2d53558c287948 100644 (file)
@@ -3178,7 +3178,8 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
        INIT_LIST_HEAD(&ha->vp_list);
 
        /* Allocate memory for our loop_id bitmap */
-       ha->loop_id_map = kzalloc(LOOPID_MAP_SIZE, GFP_KERNEL);
+       ha->loop_id_map = kzalloc(BITS_TO_LONGS(LOOPID_MAP_SIZE) * sizeof(long),
+           GFP_KERNEL);
        if (!ha->loop_id_map)
                goto fail_async_pd;
        else {