diff mbox

[opensm] Handle memory allocation failure in osm_db_domain_init()

Message ID 92a44805-9cab-4ae1-9994-39f7739aa5c7@default (mailing list archive)
State Accepted
Delegated to: Hal Rosenstock
Headers show

Commit Message

Line Holen Sept. 12, 2013, 8:14 a.m. UTC
Signed-off-by: Line Holen <Line.Holen@oracle.com>

---

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Hal Rosenstock Sept. 12, 2013, 1:48 p.m. UTC | #1
On 9/12/2013 4:14 AM, Line Holen wrote:
> Signed-off-by: Line Holen <Line.Holen@oracle.com>

Thanks. Applied.

-- Hal
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/opensm/osm_db_files.c b/opensm/osm_db_files.c
index 513cf85..9219722 100644
--- a/opensm/osm_db_files.c
+++ b/opensm/osm_db_files.c
@@ -2,6 +2,7 @@ 
  * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
  * Copyright (c) 2002-2007 Mellanox Technologies LTD. All rights reserved.
  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -218,17 +219,34 @@  osm_db_domain_t *osm_db_domain_init(IN osm_db_t * p_db, IN const char *domain_na
 
 	/* allocate a new domain object */
 	p_domain = malloc(sizeof(osm_db_domain_t));
-	CL_ASSERT(p_domain != NULL);
+	if (p_domain == NULL) {
+		OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 610C: "
+			"Failed to allocate domain memory\n");
+		goto Exit;
+	}
 
 	p_domain_imp = malloc(sizeof(osm_db_domain_imp_t));
-	CL_ASSERT(p_domain_imp != NULL);
+	if (p_domain_imp == NULL) {
+		OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 610D: "
+			"Failed to allocate domain_imp memory\n");
+		free(p_domain);
+		p_domain = NULL;
+		goto Exit;
+	}
 
 	path_len = strlen(((osm_db_imp_t *) p_db->p_db_imp)->db_dir_name)
 	    + strlen(domain_name) + 2;
 
 	/* set the domain file name */
 	p_domain_imp->file_name = malloc(path_len);
-	CL_ASSERT(p_domain_imp->file_name != NULL);
+	if (p_domain_imp->file_name == NULL) {
+		OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 610E: "
+			"Failed to allocate file_name memory\n");
+		free(p_domain_imp);
+		free(p_domain);
+		p_domain = NULL;
+		goto Exit;
+	}
 	snprintf(p_domain_imp->file_name, path_len, "%s/%s",
 		 ((osm_db_imp_t *) p_db->p_db_imp)->db_dir_name, domain_name);