On 8/30/2018 5:23 AM, Honggang LI wrote: > From: Honggang Li <honli@xxxxxxxxxx> > > Issue was found by Coverity. > > To observer this resource leak, just input this command in the console: > > OpenSM $ dump_portguid file /tmp/c file /tmp/d . > > then: > > ls -l /proc/<opensm-pid>/fd > > You will find /tmp/c was not closed. > > Error: RESOURCE_LEAK (CWE-772): [#def5] > opensm-3.3.20/opensm/osm_console.c:1682: alloc_fn: Storage is returned from allocation function "fopen". > opensm-3.3.20/opensm/osm_console.c:1682: var_assign: Assigning: "output" = storage returned from "fopen(p_cmd, "w+")". > opensm-3.3.20/opensm/osm_console.c:1682: overwrite_var: Overwriting "output" in "output = fopen(p_cmd, "w+")" leaks the storage that "output" points to. > |# 1680| p_cmd = next_token(p_last); > |# 1681| if (p_cmd) { > |# 1682|-> output = fopen(p_cmd, "w+"); > |# 1683| if (output == NULL) { > |# 1684| fprintf(out, > > Signed-off-by: Honggang Li <honli@xxxxxxxxxx> Thanks. Applied. -- Hal