From 569685b75272b49264cbd2f6a10d1fa512672e06 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Mon, 24 Feb 2014 16:01:30 +0100 Subject: [PATCH] android/avctp: Fix failing silently if uinput is not initialized This adds a check for uinput before attempting to use send_key and if it is not initialized response with AVC_CTYPE_NOT_IMPLEMENTED which is the same code used when a unkown key is received. --- android/avctp.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/android/avctp.c b/android/avctp.c index 9bfb191c0..8a0d6a166 100644 --- a/android/avctp.c +++ b/android/avctp.c @@ -284,9 +284,6 @@ static int send_event(int fd, uint16_t type, uint16_t code, int32_t value) static void send_key(int fd, uint16_t key, int pressed) { - if (fd < 0) - return; - send_event(fd, EV_KEY, key, pressed); send_event(fd, EV_SYN, SYN_REPORT, 0); } @@ -335,6 +332,12 @@ static size_t handle_panel_passthrough(struct avctp *session, goto done; } + if (session->uinput < 0) { + DBG("AV/C: uinput not initialized"); + *code = AVC_CTYPE_NOT_IMPLEMENTED; + return 0; + } + for (i = 0; key_map[i].name != NULL; i++) { uint8_t key_quirks; -- 2.47.3