mirror of
https://github.com/stefanberger/swtpm.git
synced 2026-08-09 22:15:35 +00:00
swtpm: fix memory leak related to tpmstate directory
This patch fixes a memory leak before process exit. Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
This commit is contained in:
parent
9c8202ed79
commit
fc36ef35ea
@ -1298,6 +1298,7 @@ static void ptm_cleanup(void)
|
||||
{
|
||||
pidfile_remove();
|
||||
log_global_free();
|
||||
tpmstate_global_free();
|
||||
}
|
||||
|
||||
static const struct cuse_lowlevel_ops clops = {
|
||||
|
||||
@ -66,6 +66,7 @@
|
||||
#include "utils.h"
|
||||
#include "mainloop.h"
|
||||
#include "ctrlchannel.h"
|
||||
#include "tpmstate.h"
|
||||
|
||||
/* local variables */
|
||||
static int notify_fd[2] = {-1, -1};
|
||||
@ -178,6 +179,7 @@ static void swtpm_cleanup(struct ctrlchannel *cc, struct server *server)
|
||||
ctrlchannel_free(cc);
|
||||
server_free(server);
|
||||
log_global_free();
|
||||
tpmstate_global_free();
|
||||
}
|
||||
|
||||
int swtpm_main(int argc, char **argv, const char *prgname, const char *iface)
|
||||
|
||||
@ -69,6 +69,7 @@
|
||||
#ifdef WITH_VTPM_PROXY
|
||||
#include "vtpm_proxy.h"
|
||||
#endif
|
||||
#include "tpmstate.h"
|
||||
|
||||
/* local variables */
|
||||
static int notify_fd[2] = {-1, -1};
|
||||
@ -199,6 +200,7 @@ static void swtpm_cleanup(struct ctrlchannel *cc)
|
||||
pidfile_remove();
|
||||
ctrlchannel_free(cc);
|
||||
log_global_free();
|
||||
tpmstate_global_free();
|
||||
}
|
||||
|
||||
int swtpm_chardev_main(int argc, char **argv, const char *prgname, const char *iface)
|
||||
|
||||
@ -60,6 +60,12 @@ int tpmstate_set_dir(char *tpmstatedir)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void tpmstate_global_free(void)
|
||||
{
|
||||
free(g_tpmstatedir);
|
||||
g_tpmstatedir = NULL;
|
||||
}
|
||||
|
||||
const char *tpmstate_get_dir(void)
|
||||
{
|
||||
if (g_tpmstatedir)
|
||||
|
||||
@ -44,5 +44,6 @@ int tpmstate_set_dir(char *tpmstatdir);
|
||||
const char *tpmstate_get_dir(void);
|
||||
int tpmstate_set_mode(mode_t mode);
|
||||
mode_t tpmstate_get_mode(void);
|
||||
void tpmstate_global_free(void);
|
||||
|
||||
#endif /* _SWTPM_TPMSTATE_H_ */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user