[IBAL] add sanity check for port_num field in av verbs. [mlnx: 3052]
authorleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 27 Aug 2008 16:56:46 +0000 (16:56 +0000)
committerleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 27 Aug 2008 16:56:46 +0000 (16:56 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@1530 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

core/al/user/ual_av.c

index 24669ab..8ce7f34 100644 (file)
@@ -58,6 +58,16 @@ ual_get_gid_index(
        uint16_t                        i;\r
 \r
        ci_ca_lock_attr( p_ci_ca );\r
+\r
+       // sanity check\r
+       if (port_num == 0 || port_num > p_ci_ca->p_user_attr->num_ports)\r
+       {\r
+               AL_PRINT(TRACE_LEVEL_WARNING ,AL_DBG_AV,\r
+                       ("UAL_GET_GID_INDEX: invalid port number specified (%d)\n", port_num) );\r
+               status = IB_INVALID_PORT;\r
+               goto out;\r
+       }\r
+\r
        p_port_attr = &p_ci_ca->p_user_attr->p_port_attr[port_num];\r
        for( i = 0; i < p_port_attr->num_gids; i++ )\r
        {\r
@@ -68,6 +78,8 @@ ual_get_gid_index(
                        break;\r
                }\r
        }\r
+\r
+out:\r
        ci_ca_unlock_attr( p_ci_ca );\r
 \r
        return status;\r