Re: [PATCH] osm_console.c: fix resource leak in dump_portguid_parse

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux