diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2015-03-15 16:37:39 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2015-03-15 17:26:58 -0400 |
commit | ad8780c96999c99f5aefb00193f2e3d68b1db217 (patch) | |
tree | 3ed0a0021366a02b25a4c4a7f74bb8843caba9aa /src | |
parent | 0daa5666da6fab8864e313dd594a2648d882e0cf (diff) |
logind: check return value of session_release
It allocates memory, so it can fail.
CID #1237527.
Diffstat (limited to 'src')
-rw-r--r-- | src/login/logind-dbus.c | 4 | ||||
-rw-r--r-- | src/login/logind-session.c | 18 | ||||
-rw-r--r-- | src/login/logind-session.h | 2 |
3 files changed, 14 insertions, 10 deletions
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index b28d280939..a3d49efbdd 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -827,7 +827,9 @@ static int method_release_session(sd_bus *bus, sd_bus_message *message, void *us if (r < 0) return r; - session_release(session); + r = session_release(session); + if (r < 0) + return r; return sd_bus_reply_method_return(message, NULL); } diff --git a/src/login/logind-session.c b/src/login/logind-session.c index 8d33579a01..59f765782a 100644 --- a/src/login/logind-session.c +++ b/src/login/logind-session.c @@ -701,18 +701,20 @@ static int release_timeout_callback(sd_event_source *es, uint64_t usec, void *us return 0; } -void session_release(Session *s) { +int session_release(Session *s) { assert(s); if (!s->started || s->stopping) - return; + return 0; + + if (s->timer_event_source) + return 0; - if (!s->timer_event_source) - sd_event_add_time(s->manager->event, - &s->timer_event_source, - CLOCK_MONOTONIC, - now(CLOCK_MONOTONIC) + RELEASE_USEC, 0, - release_timeout_callback, s); + return sd_event_add_time(s->manager->event, + &s->timer_event_source, + CLOCK_MONOTONIC, + now(CLOCK_MONOTONIC) + RELEASE_USEC, 0, + release_timeout_callback, s); } bool session_is_active(Session *s) { diff --git a/src/login/logind-session.h b/src/login/logind-session.h index 0505f7f0bd..9305dca83f 100644 --- a/src/login/logind-session.h +++ b/src/login/logind-session.h @@ -137,7 +137,7 @@ int session_create_fifo(Session *s); int session_start(Session *s); int session_stop(Session *s, bool force); int session_finalize(Session *s); -void session_release(Session *s); +int session_release(Session *s); int session_save(Session *s); int session_load(Session *s); int session_kill(Session *s, KillWho who, int signo); |