[PATCH 29/38] trace-cmd record: prevent memory leak in setup_network()

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

 



Because of the again label, msg_handle can be already allocated if we
exit after we got a negative socket file descriptor. Free it there.

Fixes a RESOURCE_LEAK error (CWE-772)

Signed-off-by: Jerome Marchand <jmarchan@xxxxxxxxxx>
---
 tracecmd/trace-record.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index b4cbd438..770e775b 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -3903,6 +3903,7 @@ static struct tracecmd_msg_handle *setup_network(struct buffer_instance *instanc
 
 	if (sfd < 0) {
 		free(thost);
+		free(msg_handle);
 		return NULL;
 	}
 
-- 
2.44.0





[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux