1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-04 22:21:55 +03:00

bus: avoid using m->kdbus after freeing it

m->kdbus could be freed before it is released. Changing the
order fixes the issue.

Found with Coverity. Fixes: CID#1237798
This commit is contained in:
Philippe De Swert 2014-09-10 12:20:38 +03:00 committed by David Herrmann
parent 393a5ba09f
commit fd989a0bc9

View File

@ -127,9 +127,6 @@ static void message_free(sd_bus_message *m) {
message_reset_parts(m); message_reset_parts(m);
if (m->free_kdbus)
free(m->kdbus);
if (m->release_kdbus) { if (m->release_kdbus) {
uint64_t off; uint64_t off;
@ -137,6 +134,9 @@ static void message_free(sd_bus_message *m) {
ioctl(m->bus->input_fd, KDBUS_CMD_FREE, &off); ioctl(m->bus->input_fd, KDBUS_CMD_FREE, &off);
} }
if (m->free_kdbus)
free(m->kdbus);
sd_bus_unref(m->bus); sd_bus_unref(m->bus);
if (m->free_fds) { if (m->free_fds) {