Skip to contentSkip to conversation

opensm: fixed memory leak in osm_console()

PATCH New Alex Netes 1 participant 2 messages Mar 7, 2011 1 message not in the archive InfiniBand

lore
Share & tools
lore

Alex Netes

author
#0 lore raw

PATCH 1/1 opensm: fixed memory leak in osm_console()

There is a scenario that fopen will overwrite output variable.

---
 opensm/osm_console.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
opensm/osm_console.c +2 -0
index fad80ad..7003508 100644
@@ -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,
Signature · 6 lines
1.7.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author
#2 lore raw

PATCH v2 1/1 opensm: fixed memory leak in osm_console()

In reply to a message not in the archive

Variable temp is unsigned.

Changes from v1:
Changed strtol() to strtoul()
Added 2 more cases 'p' and 'l'

---
 opensm/main.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)
opensm/main.c +7 -7
index 756fe6f..b3abdbb 100644
@@ -811,7 +811,7 @@ int main(int argc, char *argv[])
 			break;
 
 		case 'l':
-			temp = strtol(optarg, NULL, 0);
+			temp = strtoul(optarg, NULL, 0);
 			if (temp > 7) {
 				fprintf(stderr,
 					"ERROR: LMC must be 7 or less.\n");
@@ -876,8 +876,8 @@ int main(int argc, char *argv[])
 			break;
 
 		case 'p':
-			temp = strtol(optarg, NULL, 0);
-			if (0 > temp || 15 < temp) {
+			temp = strtoul(optarg, NULL, 0);
+			if (temp > 15) {
 				fprintf(stderr,
 					"ERROR: priority must be between 0 and 15\n");
 				return -1;
@@ -986,8 +986,8 @@ int main(int argc, char *argv[])
 			opt.do_mesh_analysis = TRUE;
 			break;
 		case 6:
-			temp = strtol(optarg, NULL, 0);
-			if (temp < 0 || temp >= IB_MAX_NUM_VLS) {
+			temp = strtoul(optarg, NULL, 0);
+			if (temp >= IB_MAX_NUM_VLS) {
 				fprintf(stderr,
 					"ERROR: starting lash vl must be between 0 and 15\n");
 				return -1;
@@ -996,8 +996,8 @@ int main(int argc, char *argv[])
 			printf(" LASH starting VL = %d\n", opt.lash_start_vl);
 			break;
 		case 7:
-			temp = strtol(optarg, NULL, 0);
-			if (temp < 0 || temp > 15) {
+			temp = strtoul(optarg, NULL, 0);
+			if (temp > 15) {
 				fprintf(stderr,
 					"ERROR: SM's SL must be between 0 and 15\n");
 				return -1;
Signature · 6 lines
1.7.3.4

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