From patchwork Thu Sep 12 08:14:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Line Holen X-Patchwork-Id: 2876841 X-Patchwork-Delegate: hal@mellanox.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5CDCE9F486 for ; Thu, 12 Sep 2013 08:14:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2E67E20257 for ; Thu, 12 Sep 2013 08:14:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 78B17202DB for ; Thu, 12 Sep 2013 08:14:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757680Ab3ILIOU (ORCPT ); Thu, 12 Sep 2013 04:14:20 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:42659 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757650Ab3ILIOT convert rfc822-to-8bit (ORCPT ); Thu, 12 Sep 2013 04:14:19 -0400 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r8C8EF0q026621 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 12 Sep 2013 08:14:15 GMT Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r8C8EDAX015241 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 12 Sep 2013 08:14:14 GMT Received: from abhmt114.oracle.com (abhmt114.oracle.com [141.146.116.66]) by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r8C8ED2d006939; Thu, 12 Sep 2013 08:14:13 GMT MIME-Version: 1.0 Message-ID: <92a44805-9cab-4ae1-9994-39f7739aa5c7@default> Date: Thu, 12 Sep 2013 01:14:13 -0700 (PDT) From: Line Holen To: Hal Cc: Linux-Rdma Subject: [PATCH opensm] Handle memory allocation failure in osm_db_domain_init() X-Mailer: Zimbra on Oracle Beehive Content-Disposition: inline X-Source-IP: ucsinet21.oracle.com [156.151.31.93] Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Line Holen --- -- 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 --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);