[systemd-commits] stable Branch 'v208-stable' - src/login

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Tue Mar 4 22:34:44 PST 2014


 src/login/logind-session-device.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 66a28b3bec25e0456771db7ac356ad58793c337e
Author: David Herrmann <dh.herrmann at gmail.com>
Date:   Thu Nov 28 14:51:40 2013 +0100

    logind: ignore failing close() on session-devices
    
    Unfortunately, close() on a revoked/removed character-device fails with
    ENODEV. I tried tracking this down in the kernel, but couldn't figure out
    were exactly it comes from. However, can be easily reproduced with:
      fd = open("/dev/input/event0", O_RDWR);
      ioctl(fd, EVIOCREVOKE, 0);
      r = close(fd);
    A second close on @fd would return EBADF so the close is actually valid.
    
    We simply ignore close() errors for all session-devices as their access
    may be revoked asynchronously, or the device might get unplugged.
    We use close_nointr() in case anyone ever looks at the return value (or
    anyone runs "grep 'close(' -r src/" to find broken close() calls).
    
    Fixes:
      systemd-logind[31992]: Assertion 'close_nointr(fd) == 0' failed at src/shared/util.c:185, function close_nointr_nofail(). Aborting.
    
    (cherry picked from commit d1107170f9e0fa2cb6e8d18586a003f0d96abfc3)

diff --git a/src/login/logind-session-device.c b/src/login/logind-session-device.c
index 6605935..fd02b43 100644
--- a/src/login/logind-session-device.c
+++ b/src/login/logind-session-device.c
@@ -162,7 +162,7 @@ static int session_device_open(SessionDevice *sd, bool active) {
                          * state. */
                         r = sd_drmsetmaster(fd);
                         if (r < 0) {
-                                close(fd);
+                                close_nointr(fd);
                                 return r;
                         }
                 } else {
@@ -209,7 +209,7 @@ static int session_device_start(SessionDevice *sd) {
                 r = session_device_open(sd, true);
                 if (r < 0)
                         return r;
-                close_nointr_nofail(sd->fd);
+                close_nointr(sd->fd);
                 sd->fd = r;
                 break;
         case DEVICE_TYPE_UNKNOWN:
@@ -407,7 +407,7 @@ void session_device_free(SessionDevice *sd) {
 
         session_device_stop(sd);
         session_device_notify(sd, SESSION_DEVICE_RELEASE);
-        close_nointr_nofail(sd->fd);
+        close_nointr(sd->fd);
 
         LIST_REMOVE(SessionDevice, sd_by_device, sd->device->session_devices, sd);
 



More information about the systemd-commits mailing list