Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2337173ybz; Thu, 23 Apr 2020 16:16:41 -0700 (PDT) X-Google-Smtp-Source: APiQypIvUaSmMncO+g4RpkA+/mPeSKBL3hUyVxyIn4u0BlyF1HbT8j002E2a1o15OPj5CKiKHV3b X-Received: by 2002:a17:906:2296:: with SMTP id p22mr4658918eja.269.1587683801317; Thu, 23 Apr 2020 16:16:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587683801; cv=none; d=google.com; s=arc-20160816; b=lIu+nTdlslvx1D+fDgVDf4aWvny5+PvXiGZJF4+xsouOHwgdAjhmID2rvaQfB3PHmj FtWr2tC7X59Kn7CVUmhTETmwl3jMBNWP/UDi6hT3I/LqKrppd6muP6sLE8vtzf9PWygL 21y0o245mBLKqFt83tceFnu2nk5RoKxx9rZYl1IR2vijoIcLUH3vbraxLrsVcm8SuMmd kSj0zsa7RGBw/eDQK3rl9q/w+5Su1g+2xbHC+6kNRvpkgfDdnF/kvUPb9r7N7kXbvHKH kfVq1CP7yScTatgoj5NflEWLl4U+e1BJLAbkSv+lXU3DGLeyGj5DCKEtuJMpg5mXl1qr qPNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=g57DYCHnRspYVCEVpr95niZd+mU7wvJzAH71iK4U+pc=; b=XrvE5a8FDUJC8QtPog9GoawP1Jhha1QgQHblIu26qHMK4HV6PED8Ev+NWDqLCbl8fz NHcUZjDM0vTEMW1YK03R7/TzmLv62P0cZ4ssGq5jayM6Bt/UB62EUqK/4s2fi38zjEx6 7p27fJi8miNa/IwQeJsGz3eiibtoz6pLV9HPYLsUfMO0oafbgemh2sXGJt0PnE4zCrD0 BIhrFfjYqpUSkgJtdsnutwWmLO3kwzIEUuJbQ2GorRkTzkpqj3fyJsw/95OZTF9ycX4O fGFpTSf6RoIXq31Mde7LjoOex2L35DKEfmeD8thyxg9jyHXtCNUa4L4EW6vryavsDLLE MgdA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g24si1998121edu.104.2020.04.23.16.16.18; Thu, 23 Apr 2020 16:16:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729128AbgDWXNs (ORCPT + 99 others); Thu, 23 Apr 2020 19:13:48 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:49998 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728485AbgDWXGu (ORCPT ); Thu, 23 Apr 2020 19:06:50 -0400 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1jRkvY-0004mt-Sy; Fri, 24 Apr 2020 00:06:40 +0100 Received: from ben by deadeye with local (Exim 4.93) (envelope-from ) id 1jRkvV-00E6vU-3i; Fri, 24 Apr 2020 00:06:37 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, Denis Kirjanov , "Jiri Kosina" , "Linus Torvalds" Date: Fri, 24 Apr 2020 00:06:38 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 171/245] HID: hidraw, uhid: Always report EPOLLOUT In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.83-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Jiri Kosina commit 9e635c2851df6caee651e589fbf937b637973c91 upstream. hidraw and uhid device nodes are always available for writing so we should always report EPOLLOUT and EPOLLWRNORM bits, not only in the cases when there is nothing to read. Reported-by: Linus Torvalds Fixes: be54e7461ffdc ("HID: uhid: Fix returning EPOLLOUT from uhid_char_poll") Fixes: 9f3b61dc1dd7b ("HID: hidraw: Fix returning EPOLLOUT from hidraw_poll") Signed-off-by: Jiri Kosina [bwh: Backported to 3.16: - Use unsigned int type instead of __poll_t - s/EPOLL/POLL/g] Signed-off-by: Ben Hutchings --- drivers/hid/hidraw.c | 7 ++++--- drivers/hid/uhid.c | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) --- a/drivers/hid/hidraw.c +++ b/drivers/hid/hidraw.c @@ -262,13 +262,14 @@ out: static unsigned int hidraw_poll(struct file *file, poll_table *wait) { struct hidraw_list *list = file->private_data; + unsigned int mask = POLLOUT | POLLWRNORM; /* hidraw is always writable */ poll_wait(file, &list->hidraw->wait, wait); if (list->head != list->tail) - return POLLIN | POLLRDNORM; + mask |= POLLIN | POLLRDNORM; if (!list->hidraw->exist) - return POLLERR | POLLHUP; - return POLLOUT | POLLWRNORM; + mask |= POLLERR | POLLHUP; + return mask; } static int hidraw_open(struct inode *inode, struct file *file) --- a/drivers/hid/uhid.c +++ b/drivers/hid/uhid.c @@ -720,13 +720,14 @@ unlock: static unsigned int uhid_char_poll(struct file *file, poll_table *wait) { struct uhid_device *uhid = file->private_data; + unsigned int mask = POLLOUT | POLLWRNORM; /* uhid is always writable */ poll_wait(file, &uhid->waitq, wait); if (uhid->head != uhid->tail) - return POLLIN | POLLRDNORM; + mask |= POLLIN | POLLRDNORM; - return POLLOUT | POLLWRNORM; + return mask; } static const struct file_operations uhid_fops = {