[PATCH] opensm: fixed memory leak in osm_console()
There is a scenario that fopen will overwrite output variable. Signed-off-by: Alex Netes ale...@mellanox.com --- opensm/osm_console.c |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/opensm/osm_console.c b/opensm/osm_console.c index fad80ad..7003508 100644 --- a/opensm/osm_console.c +++ b/opensm/osm_console.c @@ -1279,6 +1279,8 @@ static void dump_portguid_parse(char **p_last, osm_opensm_t * p_osm, FILE * out) if (strcmp(p_cmd, file) == 0) { p_cmd = next_token(p_last); if (p_cmd) { + if (output != out) + fclose(output); output = fopen(p_cmd, w+); if (output == NULL) { fprintf(out, -- 1.7.3.4 -- To unsubscribe from this list: send the line unsubscribe linux-rdma in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] opensm: Fixed pointer validity check in report_torus_changes()
struct torus *nt should be checked for validity before getting assignments. Signed-off-by: Alex Netes ale...@mellanox.com --- opensm/osm_torus.c | 10 +++--- 1 files changed, 7 insertions(+), 3 deletions(-) diff --git a/opensm/osm_torus.c b/opensm/osm_torus.c index add3cf9..7a2c252 100644 --- a/opensm/osm_torus.c +++ b/opensm/osm_torus.c @@ -7423,13 +7423,17 @@ void report_torus_changes(struct torus *nt, struct torus *ot) { unsigned cnt = 0; unsigned i, j, k; - unsigned x_sz = nt-x_sz; - unsigned y_sz = nt-y_sz; - unsigned z_sz = nt-z_sz; + unsigned x_sz; + unsigned y_sz; + unsigned z_sz; if (!(nt ot)) return; + x_sz = nt-x_sz; + y_sz = nt-y_sz; + z_sz = nt-z_sz; + if (x_sz != ot-x_sz) { cnt++; OSM_LOG(nt-osm-log, OSM_LOG_INFO, -- 1.7.3.4 -- To unsubscribe from this list: send the line unsubscribe linux-rdma in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] opensm: removed unnecessary checks in main()
Variable temp is unsigned. Signed-off-by: Alex Netes ale...@mellanox.com --- opensm/main.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/opensm/main.c b/opensm/main.c index 756fe6f..ef4b805 100644 --- a/opensm/main.c +++ b/opensm/main.c @@ -987,7 +987,7 @@ int main(int argc, char *argv[]) break; case 6: temp = strtol(optarg, NULL, 0); - if (temp 0 || temp = IB_MAX_NUM_VLS) { + if (temp = IB_MAX_NUM_VLS) { fprintf(stderr, ERROR: starting lash vl must be between 0 and 15\n); return -1; @@ -997,7 +997,7 @@ int main(int argc, char *argv[]) break; case 7: temp = strtol(optarg, NULL, 0); - if (temp 0 || temp 15) { + if (temp 15) { fprintf(stderr, ERROR: SM's SL must be between 0 and 15\n); return -1; -- 1.7.3.4 -- To unsubscribe from this list: send the line unsubscribe linux-rdma in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] opensm: fixed potential memory leak in osm_ucast_ftree()
Need to free all the allocated variables in case of error. Signed-off-by: Alex Netes ale...@mellanox.com --- opensm/osm_ucast_ftree.c | 26 +- 1 files changed, 21 insertions(+), 5 deletions(-) diff --git a/opensm/osm_ucast_ftree.c b/opensm/osm_ucast_ftree.c index 11980cc..51e252a 100644 --- a/opensm/osm_ucast_ftree.c +++ b/opensm/osm_ucast_ftree.c @@ -554,25 +554,40 @@ static ftree_sw_t *sw_create(IN ftree_fabric_t * p_ftree, p_sw-down_port_groups = (ftree_port_group_t **) malloc(ports_num * sizeof(ftree_port_group_t *)); + if (p_sw-down_port_groups == NULL) + goto FREE_P_SW; + p_sw-up_port_groups = (ftree_port_group_t **) malloc(ports_num * sizeof(ftree_port_group_t *)); + if (p_sw-sibling_port_groups == NULL) + goto FREE_DOWN; + p_sw-sibling_port_groups = (ftree_port_group_t **) malloc(ports_num * sizeof(ftree_port_group_t *)); - - if (!p_sw-down_port_groups || !p_sw-up_port_groups - || !p_sw-sibling_port_groups) - return NULL; + if (p_sw-sibling_port_groups == NULL) + goto FREE_UP; /* initialize lft buffer */ memset(p_osm_sw-new_lft, OSM_NO_PATH, p_osm_sw-lft_size); p_sw-hops = malloc((p_osm_sw-max_lid_ho + 1) * sizeof(*(p_sw-hops))); if (p_sw-hops == NULL) - return NULL; + goto FREE_SIBLING; + memset(p_sw-hops, OSM_NO_PATH, p_osm_sw-max_lid_ho + 1); return p_sw; + +FREE_SIBLING: + free(p_sw-sibling_port_groups); +FREE_UP: + free(p_sw-up_port_groups); +FREE_DOWN: + free(p_sw-down_port_groups); +FREE_P_SW: + free(p_sw); + return NULL; } /* sw_create() */ /***/ @@ -1662,6 +1677,7 @@ static int fabric_create_leaf_switch_array(IN ftree_fabric_t * p_ftree) if (!p_ftree-leaf_switches) { osm_log(p_ftree-p_osm-log, OSM_LOG_SYS, Fat-tree routing: Memory allocation failed\n); + free(all_switches_at_leaf_level); res = -1; goto Exit; } -- 1.7.3.4 -- To unsubscribe from this list: send the line unsubscribe linux-rdma in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] opensm: fixed sizeof of pointer allocation in osm_ucast_lash()
This fix is a cosmetic one, but this is the corect way to define sizeof in malloc. Signed-off-by: Alex Netes ale...@mellanox.com --- opensm/osm_ucast_lash.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/opensm/osm_ucast_lash.c b/opensm/osm_ucast_lash.c index 0bd1827..739eedd 100644 --- a/opensm/osm_ucast_lash.c +++ b/opensm/osm_ucast_lash.c @@ -710,13 +710,13 @@ static int init_lash_structures(lash_t * p_lash) /* initialise cdg_vertex_matrix[num_switches][num_switches][num_switches] */ p_lash-cdg_vertex_matrix = - (cdg_vertex_t ) malloc(vl_min * sizeof(cdg_vertex_t )); + (cdg_vertex_t ) malloc(vl_min * sizeof(cdg_vertex_t ***)); if (p_lash-cdg_vertex_matrix == NULL) goto Exit_Mem_Error; for (i = 0; i vl_min; i++) { p_lash-cdg_vertex_matrix[i] = (cdg_vertex_t ***) malloc(num_switches * - sizeof(cdg_vertex_t ***)); + sizeof(cdg_vertex_t **)); if (p_lash-cdg_vertex_matrix[i] == NULL) goto Exit_Mem_Error; -- 1.7.3.4 -- To unsubscribe from this list: send the line unsubscribe linux-rdma in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] opensm: fixed potential null variable dereferencing in libvendor
lru might be uninitialized in case when m-version = ~0. Signed-off-by: Alex Netes ale...@mellanox.com --- libvendor/osm_vendor_ibumad.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/libvendor/osm_vendor_ibumad.c b/libvendor/osm_vendor_ibumad.c index be2dda2..5cd6f46 100644 --- a/libvendor/osm_vendor_ibumad.c +++ b/libvendor/osm_vendor_ibumad.c @@ -174,7 +174,7 @@ put_madw(osm_vendor_t * p_vend, osm_madw_t * p_madw, ib_net64_t tid) pthread_mutex_unlock(p_vend-match_tbl_mutex); return; } - if (oldest m-version) { + if (oldest = m-version) { oldest = m-version; lru = m; } -- 1.7.3.4 -- To unsubscribe from this list: send the line unsubscribe linux-rdma in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] opensm: Fixed debug message in osm_vendor_send()
p_madw might be freed in umad_send(). So printing TID instead of the p_madw pointer is more accurate. Signed-off-by: Alex Netes ale...@mellanox.com --- libvendor/osm_vendor_ibumad.c |8 +--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libvendor/osm_vendor_ibumad.c b/libvendor/osm_vendor_ibumad.c index 2373803..be2dda2 100644 --- a/libvendor/osm_vendor_ibumad.c +++ b/libvendor/osm_vendor_ibumad.c @@ -1004,6 +1004,7 @@ osm_vendor_send(IN osm_bind_handle_t h_bind, int ret = -1; int is_rmpp = 0; uint32_t sent_mad_size; + uint64_t tid; #ifndef VENDOR_RMPP_SUPPORT uint32_t paylen = 0; #endif @@ -1068,13 +1069,14 @@ Resp: sent_mad_size = is_rmpp ? p_madw-mad_size - IB_SA_MAD_HDR_SIZE : p_madw-mad_size; #endif + tid = cl_ntoh64(p_mad-trans_id); if ((ret = umad_send(p_bind-port_id, p_bind-agent_id, p_vw-umad, sent_mad_size, resp_expected ? p_bind-timeout : 0, p_bind-max_retries)) 0) { OSM_LOG(p_vend-p_log, OSM_LOG_ERROR, ERR 5430: Send p_madw = %p of size %d TID 0x% PRIx64 failed %d (%m)\n, - p_madw, sent_mad_size, cl_ntoh64(p_mad-trans_id), ret); + p_madw, sent_mad_size, tid, ret); if (resp_expected) { get_madw(p_vend, p_mad-trans_id); /* remove from aging table */ p_madw-status = IB_ERROR; @@ -1089,8 +1091,8 @@ Resp: if (!resp_expected) osm_mad_pool_put(p_bind-p_mad_pool, p_madw); - OSM_LOG(p_vend-p_log, OSM_LOG_DEBUG, Completed sending %s p_madw = %p\n, - resp_expected ? request : response or unsolicited, p_madw); + OSM_LOG(p_vend-p_log, OSM_LOG_DEBUG, Completed sending %s TID 0x% PRIx64 \n, + resp_expected ? request : response or unsolicited, tid); Exit: OSM_LOG_EXIT(p_vend-p_log); return (ret); -- 1.7.3.4 -- To unsubscribe from this list: send the line unsubscribe linux-rdma in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] opensm: removed unnecessary checks in main()
On Mon, Mar 07, 2011 at 12:01:46PM +0200, Alex Netes wrote: Variable temp is unsigned. Signed-off-by: Alex Netes ale...@mellanox.com --- opensm/main.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/opensm/main.c b/opensm/main.c index 756fe6f..ef4b805 100644 --- a/opensm/main.c +++ b/opensm/main.c @@ -987,7 +987,7 @@ int main(int argc, char *argv[]) break; case 6: temp = strtol(optarg, NULL, 0); - if (temp 0 || temp = IB_MAX_NUM_VLS) { + if (temp = IB_MAX_NUM_VLS) { fprintf(stderr, ERROR: starting lash vl must be between 0 and 15\n); return -1; @@ -997,7 +997,7 @@ int main(int argc, char *argv[]) break; case 7: temp = strtol(optarg, NULL, 0); - if (temp 0 || temp 15) { + if (temp 15) { fprintf(stderr, ERROR: SM's SL must be between 0 and 15\n); return -1; -- 1.7.3.4 -- strtol() returs a long, not unsigned, therefor either temp must be changed to match (and keep the 0 tests) or a different function must be used (strtoul()?). -- JF -- To unsubscribe from this list: send the line unsubscribe linux-rdma in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] pensm/osm_qos_parser: QOS parser doesn't work after syntax error
If there was a syntax error in the QoS policy file, any subsequent parsing fails, even if the error is fixed. The reason is that the parser doesn't clean its buffer - need to clean it explicitly when exiting parsing. Signed-off-by: Aviad Yehezkel avia...@mellanox.co.il Signed-off-by: Yevgeny Kliteynik klit...@dev.mellanox.co.il --- opensm/opensm/osm_qos_parser_l.l |4 opensm/opensm/osm_qos_parser_y.y |4 2 files changed, 8 insertions(+), 0 deletions(-) diff --git a/opensm/opensm/osm_qos_parser_l.l b/opensm/opensm/osm_qos_parser_l.l index 4633e0e..559974b 100644 --- a/opensm/opensm/osm_qos_parser_l.l +++ b/opensm/opensm/osm_qos_parser_l.l @@ -355,6 +355,10 @@ QUOTED_TEXT \[^\]*\ . { SAVE_POS; yylval = strdup(yytext); return TK_TEXT;} +EOF { +YY_NEW_FILE; +yyterminate(); +} %% diff --git a/opensm/opensm/osm_qos_parser_y.y b/opensm/opensm/osm_qos_parser_y.y index 7118b79..51f72e3 100644 --- a/opensm/opensm/osm_qos_parser_y.y +++ b/opensm/opensm/osm_qos_parser_y.y @@ -149,6 +149,7 @@ extern char * yytext; extern int yylex (void); extern FILE * yyin; extern int errno; +extern void yyrestart(FILE *input_file); int yyparse(); #define RESET_BUFFER __parser_tmp_struct_reset() @@ -2354,7 +2355,10 @@ int osm_qos_parse_policy_file(IN osm_subn_t * p_subn) Exit: if (yyin) +{ +yyrestart(yyin); fclose(yyin); +} OSM_LOG_EXIT(p_qos_parser_osm_log); return res; } -- 1.6.2.4 -- To unsubscribe from this list: send the line unsubscribe linux-rdma in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] opensm: Fixed pointer validity check in report_torus_changes()
Hi Alex, On Mon, 2011-03-07 at 02:59 -0700, Alex Netes wrote: struct torus *nt should be checked for validity before getting assignments. Signed-off-by: Alex Netes ale...@mellanox.com --- opensm/osm_torus.c | 10 +++--- 1 files changed, 7 insertions(+), 3 deletions(-) diff --git a/opensm/osm_torus.c b/opensm/osm_torus.c index add3cf9..7a2c252 100644 --- a/opensm/osm_torus.c +++ b/opensm/osm_torus.c @@ -7423,13 +7423,17 @@ void report_torus_changes(struct torus *nt, struct torus *ot) { unsigned cnt = 0; unsigned i, j, k; - unsigned x_sz = nt-x_sz; - unsigned y_sz = nt-y_sz; - unsigned z_sz = nt-z_sz; + unsigned x_sz; + unsigned y_sz; + unsigned z_sz; Actually, nt is guaranteed to be non-NULL; check the only caller (torus_build_lfts()). if (!(nt ot)) return; This check for nt is redundant, I think. Only ot has any possibility of being NULL. -- Jim + x_sz = nt-x_sz; + y_sz = nt-y_sz; + z_sz = nt-z_sz; + if (x_sz != ot-x_sz) { cnt++; OSM_LOG(nt-osm-log, OSM_LOG_INFO, -- To unsubscribe from this list: send the line unsubscribe linux-rdma in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Backport patches for 2.6.37 and 2.6.38 already available?
Dear all, is there already a patch set for kernel 2.6.37 or 2.6.38? If yes, where can I get it. If this is the wrong place to ask, please point me in the right direction. Thanx, Elmar -- To unsubscribe from this list: send the line unsubscribe linux-rdma in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html