diff mbox series

[ovs-dev] pcap-file: Fix memory leak in ovs_pcap_open()

Message ID 1630498755-13520-1-git-send-email-wangyunjian@huawei.com
State Accepted
Headers show
Series [ovs-dev] pcap-file: Fix memory leak in ovs_pcap_open() | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed

Commit Message

wangyunjian Sept. 1, 2021, 12:19 p.m. UTC
In ovs_pcap_open(), we allocate memory for the 'p_file'
structure but not released when fopen fails.

Addresses-Coverity: ("Resource leak")
Fixes: b6e840aed03e ("pcap-file: Add nanosecond resolution pcap support.")
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 lib/pcap-file.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Aaron Conole Sept. 1, 2021, 1:21 p.m. UTC | #1
Yunjian Wang <wangyunjian@huawei.com> writes:

> In ovs_pcap_open(), we allocate memory for the 'p_file'
> structure but not released when fopen fails.
>
> Addresses-Coverity: ("Resource leak")
> Fixes: b6e840aed03e ("pcap-file: Add nanosecond resolution pcap support.")
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> ---

Good catch.  Thanks.

Acked-by: Aaron Conole <aconole@redhat.com>
Ilya Maximets Sept. 16, 2021, 12:56 a.m. UTC | #2
On 9/1/21 15:21, Aaron Conole wrote:
> Yunjian Wang <wangyunjian@huawei.com> writes:
> 
>> In ovs_pcap_open(), we allocate memory for the 'p_file'
>> structure but not released when fopen fails.
>>
>> Addresses-Coverity: ("Resource leak")
>> Fixes: b6e840aed03e ("pcap-file: Add nanosecond resolution pcap support.")
>> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
>> ---
> 
> Good catch.  Thanks.
> 
> Acked-by: Aaron Conole <aconole@redhat.com>


Thanks!  Applied and backported down to 2.12.

Best regards, Ilya Maximets.
diff mbox series

Patch

diff --git a/lib/pcap-file.c b/lib/pcap-file.c
index b30a11c24..41835f6f4 100644
--- a/lib/pcap-file.c
+++ b/lib/pcap-file.c
@@ -89,6 +89,7 @@  ovs_pcap_open(const char *file_name, const char *mode)
                    : mode[0] == 'w' ? "writing"
                    : "appending"),
                   ovs_strerror(errno));
+        free(p_file);
         return NULL;
     }