mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-20 14:03:39 +03:00
dlfcn: add new safe_dclose() helper
Let's allow destructing loaded module handles in our usual way that is fine with NULL handles, and also returns the NULL handle again.
This commit is contained in:
parent
6ec7a722ba
commit
f2592ef0e1
@ -24,3 +24,11 @@ int dlopen_many_sym_or_warn_sentinel(void **dlp, const char *filename, int log_l
|
|||||||
/* libbpf is a bit confused about type-safety and API compatibility. Provide a macro that can tape over that mess. Sad. */
|
/* libbpf is a bit confused about type-safety and API compatibility. Provide a macro that can tape over that mess. Sad. */
|
||||||
#define DLSYM_ARG_FORCE(arg) \
|
#define DLSYM_ARG_FORCE(arg) \
|
||||||
&sym_##arg, STRINGIFY(arg)
|
&sym_##arg, STRINGIFY(arg)
|
||||||
|
|
||||||
|
static inline void *safe_dlclose(void *p) {
|
||||||
|
if (!p)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
assert_se(dlclose(p) == 0);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
@ -111,11 +111,7 @@ void tpm2_context_destroy(struct tpm2_context *c) {
|
|||||||
sym_Esys_Finalize(&c->esys_context);
|
sym_Esys_Finalize(&c->esys_context);
|
||||||
|
|
||||||
c->tcti_context = mfree(c->tcti_context);
|
c->tcti_context = mfree(c->tcti_context);
|
||||||
|
c->tcti_dl = safe_dlclose(c->tcti_dl);
|
||||||
if (c->tcti_dl) {
|
|
||||||
dlclose(c->tcti_dl);
|
|
||||||
c->tcti_dl = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void Esys_Finalize_wrapper(ESYS_CONTEXT **c) {
|
static inline void Esys_Finalize_wrapper(ESYS_CONTEXT **c) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user