infra: safeguard free_mars_global

This commit is contained in:
Thomas Schoebel-Theuer 2020-09-15 17:42:30 +02:00
parent efbb44cf4b
commit adaecce4c8
2 changed files with 13 additions and 6 deletions

View File

@ -165,8 +165,13 @@ do { \
#define free_mars_global(_global_) \
({ \
exit_mars_global(_global_); \
brick_mem_free(_global_); \
struct mars_global *__global = (_global_); \
\
if (__global) { \
(_global_) = NULL; \
exit_mars_global(__global); \
brick_mem_free(__global); \
} \
})
extern void bind_to_dent(struct mars_dent *dent, struct say_channel **ch);

View File

@ -1189,10 +1189,12 @@ void exit_mars_global(struct mars_global *global)
void __mars_trigger(int mode)
{
if (mars_global) {
mars_global->trigger_mode |= mode;
mars_global->main_trigger = true;
wake_up_interruptible_all(&mars_global->main_event);
struct mars_global *global = mars_global;
if (global) {
global->trigger_mode |= mode;
global->main_trigger = true;
wake_up_interruptible_all(&global->main_event);
}
}