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 |
Context | Check | Description |
---|---|---|
ovsrobot/apply-robot | success | apply and check: success |
ovsrobot/github-robot-_Build_and_Test | success | github build: passed |
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>
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 --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; }
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(+)