[systemd-commits] 5 commits - src/journal src/libsystemd src/libsystemd-terminal

David Herrmann dvdhrm at kemper.freedesktop.org
Thu Sep 11 08:32:20 PDT 2014


 src/journal/coredumpctl.c               |    3 +--
 src/journal/mmap-cache.c                |   10 +++++++---
 src/libsystemd-terminal/idev-keyboard.c |    4 +++-
 src/libsystemd/sd-bus/bus-message.c     |    6 +++---
 src/libsystemd/sd-bus/sd-bus.c          |    4 +++-
 5 files changed, 17 insertions(+), 10 deletions(-)

New commits:
commit 2b347169b9046ff2d735ef23e62a8c74f5151600
Author: Philippe De Swert <philippedeswert at gmail.com>
Date:   Wed Sep 10 12:20:42 2014 +0300

    bus: unref buscreds on failure
    
    Actually unref the buscreds when we are not going to return a
    pointer to them. As when bus_creds_add_more fails we immediately
    return the error code otherwise and leak the new buscreds.
    Found with coverity. Fixes: CID#1237761

diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
index 78e91b9..83b3aa1 100644
--- a/src/libsystemd/sd-bus/sd-bus.c
+++ b/src/libsystemd/sd-bus/sd-bus.c
@@ -3339,8 +3339,10 @@ _public_ int sd_bus_get_peer_creds(sd_bus *bus, uint64_t mask, sd_bus_creds **re
         }
 
         r = bus_creds_add_more(c, mask, pid, 0);
-        if (r < 0)
+        if (r < 0) {
+                sd_bus_creds_unref(c);
                 return r;
+        }
 
         *ret = c;
         return 0;

commit b67ddc7bbe31cde7f69f9814204d9bb1d4623c47
Author: Philippe De Swert <philippedeswert at gmail.com>
Date:   Wed Sep 10 12:20:41 2014 +0300

    journal: do not leak mmaps on OOM
    
    After a section of memory is succesfully allocated, some of the following
    actions can still fail due to lack of memory. In this case -ENOMEM is
    returned without actually freeing the already mapped memory.
    Found with coverity. Fixes: CID#1237762

diff --git a/src/journal/mmap-cache.c b/src/journal/mmap-cache.c
index 7dbbb5e..908562d 100644
--- a/src/journal/mmap-cache.c
+++ b/src/journal/mmap-cache.c
@@ -496,15 +496,15 @@ static int add_mmap(
 
         c = context_add(m, context);
         if (!c)
-                return -ENOMEM;
+                goto outofmem;
 
         f = fd_add(m, fd);
         if (!f)
-                return -ENOMEM;
+                goto outofmem;
 
         w = window_add(m);
         if (!w)
-                return -ENOMEM;
+                goto outofmem;
 
         w->keep_always = keep_always;
         w->ptr = d;
@@ -522,6 +522,10 @@ static int add_mmap(
         if (ret)
                 *ret = (uint8_t*) w->ptr + (offset - w->offset);
         return 1;
+
+outofmem:
+        munmap(d, wsize);
+        return -ENOMEM;
 }
 
 int mmap_cache_get(

commit 21978bc3c90ec192130a9ea9df62a75d1262b80c
Author: David Herrmann <dh.herrmann at gmail.com>
Date:   Thu Sep 11 17:20:11 2014 +0200

    terminal: fix uninitialized variable in strerror() log message
    
    We currently print weird error-messages if xkbcommon fails (which cannot
    fail so far, but might in the future). Fix the uninitialized variable
    warnings by setting 'r' correctly.
    Thanks to Philippe De Swert for catching this (via coverity).

diff --git a/src/libsystemd-terminal/idev-keyboard.c b/src/libsystemd-terminal/idev-keyboard.c
index ab9e481..d5936b7 100644
--- a/src/libsystemd-terminal/idev-keyboard.c
+++ b/src/libsystemd-terminal/idev-keyboard.c
@@ -770,8 +770,10 @@ static int keyboard_feed_evdev(idev_keyboard *k, idev_data *data) {
                 /* TODO: update LEDs */
         }
 
-        if (num < 0)
+        if (num < 0) {
+                r = num;
                 goto error;
+        }
 
         r = keyboard_fill(k, &k->evdata, data->resync, ev->code, ev->value, num, keysyms);
         if (r < 0)

commit 48d4c7468fb5003ae45ac834de1ca85624cdd56e
Author: Philippe De Swert <philippedeswert at gmail.com>
Date:   Wed Sep 10 12:20:39 2014 +0300

    journal: do not dereference already freed patterns
    
    In case set_consume goes wrong, the pattern name has already been
    freed. So we do not try to print it in the logs, assuming the pattern
    addition print will be printed just before the failure anyway. Found
    with coverity. Fixes: CID#1237798

diff --git a/src/journal/coredumpctl.c b/src/journal/coredumpctl.c
index f5cf85a..34dcae8 100644
--- a/src/journal/coredumpctl.c
+++ b/src/journal/coredumpctl.c
@@ -110,8 +110,7 @@ static int add_match(Set *set, const char *match) {
         log_debug("Adding pattern: %s", pattern);
         r = set_consume(set, pattern);
         if (r < 0) {
-                log_error("Failed to add pattern '%s': %s",
-                          pattern, strerror(-r));
+                log_error("Failed to add pattern: %s", strerror(-r));
                 goto fail;
         }
 

commit fd989a0bc999d79719408ac28b126d9c9016bcb5
Author: Philippe De Swert <philippedeswert at gmail.com>
Date:   Wed Sep 10 12:20:38 2014 +0300

    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

diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c
index d00455a..bfb14fc 100644
--- a/src/libsystemd/sd-bus/bus-message.c
+++ b/src/libsystemd/sd-bus/bus-message.c
@@ -127,9 +127,6 @@ static void message_free(sd_bus_message *m) {
 
         message_reset_parts(m);
 
-        if (m->free_kdbus)
-                free(m->kdbus);
-
         if (m->release_kdbus) {
                 uint64_t off;
 
@@ -137,6 +134,9 @@ static void message_free(sd_bus_message *m) {
                 ioctl(m->bus->input_fd, KDBUS_CMD_FREE, &off);
         }
 
+        if (m->free_kdbus)
+                free(m->kdbus);
+
         sd_bus_unref(m->bus);
 
         if (m->free_fds) {



More information about the systemd-commits mailing list