]> err.no Git - systemd/commitdiff
libudev: ctrl - fix refcounting in connection handling
authorKay Sievers <kay.sievers@vrfy.org>
Wed, 13 Apr 2011 16:21:47 +0000 (18:21 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Wed, 13 Apr 2011 16:21:47 +0000 (18:21 +0200)
libudev/libudev-ctrl.c

index cea1b7f55b0d359a4bfa62916d23e0a028abd6de..2d2dd3a0bee63bf419aa88ef9e906c1d072d9fa8 100644 (file)
@@ -327,16 +327,15 @@ struct udev_ctrl_msg *udev_ctrl_receive_msg(struct udev_ctrl_connection *conn)
                return NULL;
        uctrl_msg->refcount = 1;
        uctrl_msg->conn = conn;
+       udev_ctrl_connection_ref(conn);
 
        iov.iov_base = &uctrl_msg->ctrl_msg_wire;
        iov.iov_len = sizeof(struct udev_ctrl_msg_wire);
-
        memset(&smsg, 0x00, sizeof(struct msghdr));
        smsg.msg_iov = &iov;
        smsg.msg_iovlen = 1;
        smsg.msg_control = cred_msg;
        smsg.msg_controllen = sizeof(cred_msg);
-
        size = recvmsg(conn->sock, &smsg, 0);
        if (size <  0) {
                err(udev, "unable to receive user udevd message: %m\n");
@@ -361,7 +360,6 @@ struct udev_ctrl_msg *udev_ctrl_receive_msg(struct udev_ctrl_connection *conn)
        }
 
        dbg(udev, "created ctrl_msg %p (%i)\n", uctrl_msg, uctrl_msg->ctrl_msg_wire.type);
-       udev_ctrl_connection_ref(conn);
        return uctrl_msg;
 err:
        udev_ctrl_msg_unref(uctrl_msg);