changeset 12637:ea0ebc6fc051

6800232 memory leaks in ibdm_update_port_attr
author Justin Frank <Justin.Frank@Sun.COM>
date Wed, 16 Jun 2010 20:01:06 -0700
parents 13b5d698941e
children 4cce88587bfc
files usr/src/uts/common/io/ib/mgt/ibdm/ibdm.c
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/common/io/ib/mgt/ibdm/ibdm.c	Wed Jun 16 16:57:34 2010 -0700
+++ b/usr/src/uts/common/io/ib/mgt/ibdm/ibdm.c	Wed Jun 16 20:01:06 2010 -0700
@@ -19,8 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
 /*
@@ -1052,6 +1051,8 @@
 	ibdm_hca_list_t		*head, *prev = NULL;
 	size_t			len;
 	ibdm_dp_gidinfo_t	*gidinfo;
+	ibdm_port_attr_t	*port_attr;
+	int			i;
 
 	IBTF_DPRINTF_L4("ibdm",
 	    "\thandle_hca_detach: hca_guid = 0x%llx", hca_guid);
@@ -1097,7 +1098,14 @@
 					    head->hl_next;
 				else
 					prev->hl_next = head->hl_next;
-
+				for (i = 0; i < head->hl_nports; i++) {
+					port_attr = &head->hl_port_attr[i];
+					if (port_attr->pa_pkey_tbl != NULL)
+						kmem_free(
+						    port_attr->pa_pkey_tbl,
+						    port_attr->pa_npkeys *
+						    sizeof (ibdm_pkey_tbl_t));
+				}
 				len = sizeof (ibdm_hca_list_t) +
 				    (head->hl_nports *
 				    sizeof (ibdm_port_attr_t));