Proper error handling when a keymap can't be created
The problem appears to be incorrect error handling in weston_seat_init_keyboard()
which exits
if weston_xkb_info_create()
or weston_compositor_build_global_keymap()
fails. This can be seen
with devices which aren't really keyboards (the use case I've seen are some kind of bluetooth
remotes) and the fact that the keymap role can't be created (see weston_xkb_info_create()
).
Upon un-plugging the device in cause we'll trip an assert in weston_seat_release_keyboard()
which assumes at least one reference taken (which does not happen in case a keymap can't be used in weston_seat_init_keyboard()
).
LE: For some further context, the keymap creation fails due to memfd_create()
syscall failing, which seems unlikely
to be triggered in a normal, desktop environment, but could happen if security mechanisms are in place, or are mis-configured. Thus, a easy way to replicate this bug would be to simulate this as well.