From: Dan Ben Yosef <da...@dev.mellanox.co.il>

leaks the storage that "p_accum_val" and "p_key" points to.

Signed-off-by: Dan Ben Yosef <da...@dev.mellanox.co.il>
Reviewed-by: Vladimir Koushnir <vladim...@mellanox.com>
Signed-off-by: Hal Rosenstock <h...@mellanox.com>
---
diff --git a/opensm/osm_db_files.c b/opensm/osm_db_files.c
index 0d8f36c..513cf85 100644
--- a/opensm/osm_db_files.c
+++ b/opensm/osm_db_files.c
@@ -272,7 +272,7 @@ int osm_db_restore(IN osm_db_domain_t * p_domain)
        boolean_t before_key;
        char *p_first_word, *p_rest_of_line, *p_last;
        char *p_key = NULL;
-       char *p_prev_val, *p_accum_val = NULL;
+       char *p_prev_val = NULL, *p_accum_val = NULL;
        char *endptr = NULL;
        unsigned int line_num;
 
@@ -371,12 +371,18 @@ int osm_db_restore(IN osm_db_domain_t * p_domain)
                                if (st_lookup(p_domain_imp->p_hash,
                                              (st_data_t) p_key,
                                              (void *)&p_prev_val)) {
+                                       /* if previously used we ignore this 
guid */
                                        OSM_LOG(p_log, OSM_LOG_ERROR,
                                                "ERR 6106: "
                                                "Key:%s already exists in:%s 
with value:%s."
                                                " Removing it\n", p_key,
                                                p_domain_imp->file_name,
                                                p_prev_val);
+                                               free(p_key);
+                                               p_key = NULL;
+                                               free(p_accum_val);
+                                               p_accum_val = NULL;
+                                               continue;
                                } else {
                                        p_prev_val = NULL;
                                }
@@ -391,6 +397,10 @@ int osm_db_restore(IN osm_db_domain_t * p_domain)
                                        OSM_LOG(p_log, OSM_LOG_ERROR,
                                                "ERR 610B: "
                                                "Key:%s is invalid\n", p_key);
+                                               free(p_key);
+                                               p_key = NULL;
+                                               free(p_accum_val);
+                                               p_accum_val = NULL;
                                } else {
                                        /* store our key and value */
                                        st_insert(p_domain_imp->p_hash,
@@ -404,6 +414,7 @@ int osm_db_restore(IN osm_db_domain_t * p_domain)
                                                     strlen(sLine) + 1);
                                strcpy(p_accum_val, p_prev_val);
                                free(p_prev_val);
+                               p_prev_val = NULL;
                                strcat(p_accum_val, sLine);
                        }
                }               /* in key */
--
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

Reply via email to