logind: check return value of session_release
It allocates memory, so it can fail. CID #1237527.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
sd_event_add_time(s->manager->event,
|
||||
&s->timer_event_source,
|
||||
CLOCK_MONOTONIC,
|
||||
now(CLOCK_MONOTONIC) + RELEASE_USEC, 0,
|
||||
release_timeout_callback, s);
|
||||
if (s->timer_event_source)
|
||||
return 0;
|
||||
|
||||
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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user