seat: Plug leak of deactivated fds
Only if a device had an fd and was active would an fd be closed. As devices are deactivated early on session switch, this lead to fd leakage. Close fds regardless of active state.
This commit is contained in:
parent
51c7467516
commit
8cb076d0a4
1 changed files with 16 additions and 17 deletions
33
seatd/seat.c
33
seatd/seat.c
|
@ -309,30 +309,29 @@ int seat_close_device(struct client *client, struct seat_device *seat_device) {
|
|||
|
||||
seat_device->ref_cnt--;
|
||||
if (seat_device->ref_cnt > 0) {
|
||||
// We still have more references to this device, so leave it be.
|
||||
return 0;
|
||||
}
|
||||
|
||||
// The ref count hit zero, so destroy the device
|
||||
linked_list_remove(&seat_device->link);
|
||||
if (seat_device->active && seat_device->fd != -1) {
|
||||
switch (seat_device->type) {
|
||||
case SEAT_DEVICE_TYPE_DRM:
|
||||
if (drm_drop_master(seat_device->fd) == -1) {
|
||||
log_debugf("drm_drop_master failed: %s", strerror(errno));
|
||||
if (seat_device->fd != -1) {
|
||||
if (seat_device->active) {
|
||||
switch (seat_device->type) {
|
||||
case SEAT_DEVICE_TYPE_DRM:
|
||||
if (drm_drop_master(seat_device->fd) == -1) {
|
||||
log_debugf("drm_drop_master failed: %s", strerror(errno));
|
||||
}
|
||||
break;
|
||||
case SEAT_DEVICE_TYPE_EVDEV:
|
||||
if (evdev_revoke(seat_device->fd) == -1) {
|
||||
log_debugf("evdev_revoke failed: %s", strerror(errno));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
log_error("invalid seat device type");
|
||||
abort();
|
||||
}
|
||||
break;
|
||||
case SEAT_DEVICE_TYPE_EVDEV:
|
||||
if (evdev_revoke(seat_device->fd) == -1) {
|
||||
log_debugf("evdev_revoke failed: %s", strerror(errno));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
log_error("invalid seat device type");
|
||||
abort();
|
||||
}
|
||||
close(seat_device->fd);
|
||||
seat_device->fd = -1;
|
||||
}
|
||||
free(seat_device->path);
|
||||
free(seat_device);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue