From patchwork Wed Oct 2 13:45:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 2974881 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B54129F245 for ; Wed, 2 Oct 2013 13:45:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2BE5E203DD for ; Wed, 2 Oct 2013 13:45:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 09021203A8 for ; Wed, 2 Oct 2013 13:45:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754463Ab3JBNo4 (ORCPT ); Wed, 2 Oct 2013 09:44:56 -0400 Received: from mga14.intel.com ([143.182.124.37]:35675 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754438Ab3JBNot (ORCPT ); Wed, 2 Oct 2013 09:44:49 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by azsmga102.ch.intel.com with ESMTP; 02 Oct 2013 06:44:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.90,1019,1371106800"; d="scan'208";a="404230228" Received: from paasikivi.fi.intel.com ([10.237.72.42]) by fmsmga001.fm.intel.com with ESMTP; 02 Oct 2013 06:44:46 -0700 Received: from nauris.fi.intel.com (nauris.localdomain [192.168.240.2]) by paasikivi.fi.intel.com (Postfix) with ESMTP id 63DF4203ED; Wed, 2 Oct 2013 16:44:45 +0300 (EEST) Received: by nauris.fi.intel.com (Postfix, from userid 1000) id A110C20209; Wed, 2 Oct 2013 16:45:35 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, laurent.pinchart@ideasonboard.com, teemux.tuominen@intel.com Subject: [RFC v2 3/4] v4l: vb2: Return POLLERR when polling for events and none are subscribed Date: Wed, 2 Oct 2013 16:45:15 +0300 Message-Id: <1380721516-488-4-git-send-email-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1380721516-488-1-git-send-email-sakari.ailus@linux.intel.com> References: <1380721516-488-1-git-send-email-sakari.ailus@linux.intel.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The current implementation allowed polling for events even if none were subscribed. This may be troublesome in multi-threaded applications where the thread handling the subscription is different from the one that handles the events. Signed-off-by: Sakari Ailus --- drivers/media/v4l2-core/videobuf2-core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index 79acf5e..c5dc903 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -2011,6 +2011,9 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait) if (v4l2_event_pending(fh)) res = POLLPRI; + + if (!v4l2_event_has_subscribed(fh)) + return POLLERR | POLLPRI; } if (!V4L2_TYPE_IS_OUTPUT(q->type) && !(req_events & (POLLIN | POLLRDNORM)))