Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2929216rwb; Mon, 15 Aug 2022 14:14:55 -0700 (PDT) X-Google-Smtp-Source: AA6agR44qBqkOXADXGBG5Ha9coeUmyqOpxBRKMnhQePz3Fy8riZmK/tZ8LLemCNBt/qi72jh2Dj/ X-Received: by 2002:a17:90b:1907:b0:1f3:d6:985c with SMTP id mp7-20020a17090b190700b001f300d6985cmr20869978pjb.46.1660598095314; Mon, 15 Aug 2022 14:14:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660598095; cv=none; d=google.com; s=arc-20160816; b=AypmapkpFyvWYVXvmhjjH1ihkjcWEo0xx84DYLDt4f6e/JPnc0/7GfeusFFEJBpQox MUlbyiBOwfuLWINbrz+nrT9aAi6viO9RT1/avqin02byNthSSbksSV5Fm4ffnsSYqhIu QCiMGuUSDgdarvrGZjNTWJRAV7P24koO875jQSESb7JTPEeZM4gaJoN7gpsjml5tT87E 2Mlurx9SJeAvA8AImzPwUOSR/7fIgQw+zIgWYxtynrgtnkCM0x+bmtC9pTnyGk8ZGJvY IxnU0shQFKAF7N8waf5OGO4vVSypKsjz/OPNKbXoI5CfFEdLClGyZiWb+V2l1GEsJInT 2hHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aHlmux8iWLG4oY5PyJr5ZWkWAaPhst/sdCPbFFpUtAg=; b=zpSk4j5fRpoRWmILWWbtocHgYI9zuiK6N3YsVr4lqTi6fBYyaoSJTRRbi7drJVUTCw +NHI234KaEJ12xXVPmBxuyB37MVezmSnSQTD6nomyH/4dEj7PHQcmIAp7QcjmNklAf4z zj0Ei8lPIasWERzvDXwOZi0K8uLvJsqfEjMPkQ+mmU9oSt+gamfwBOW2crnedVsqExAk N4y77dQNNpVVQMgb92UcCUyOHLERVRbceTbBkbJSAqTcWQaBGW8LaBP4R9+9ScjSm0js iSnfIY+sk60Nvt7iMiwmOaG78L/5PZIgzK9x10RAocD6UuCGOoSi5yqXenr/rVd0OTU3 DSaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gjGjeb2a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o15-20020a635a0f000000b0041bb35b5dcasi11318726pgb.576.2022.08.15.14.14.41; Mon, 15 Aug 2022 14:14:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gjGjeb2a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240801AbiHOVDT (ORCPT + 99 others); Mon, 15 Aug 2022 17:03:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346912AbiHOVBR (ORCPT ); Mon, 15 Aug 2022 17:01:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F292EC7BBE; Mon, 15 Aug 2022 12:13:23 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2B75A60693; Mon, 15 Aug 2022 19:13:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35A4BC433D6; Mon, 15 Aug 2022 19:13:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660590802; bh=3iDinCEBxPLiLOm5Rep+za2zuEXefAblH7Z3yL6QDHM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gjGjeb2a0II/UTCe3AJYxIDKH/+rP8Si0eLEWSH6RAIR958CMP1nGAruIgKuc6x9e fuxAHxP6LpqgwG/nx9vwGzPbRyjvPFY09ubpWSgiPOA4LUb7KEyXwFqfIGCxBg/Dp7 As/6T7d8O4DyG4DsFkEWIYSINg7r18I+AYDYwE3A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ming Qian , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.18 0376/1095] media: v4l2-mem2mem: prevent pollerr when last_buffer_dequeued is set Date: Mon, 15 Aug 2022 19:56:15 +0200 Message-Id: <20220815180445.252066139@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ming Qian [ Upstream commit d4de27a9b1eadd33a2e40de87a646d1bf5fef756 ] If the last buffer was dequeued from the capture queue, signal userspace. DQBUF(CAPTURE) will return -EPIPE. But if output queue is empty and capture queue is empty, v4l2_m2m_poll_for_data will return EPOLLERR, This is very easy to happen in drain. When last_buffer_dequeued is set, we shouldn't return EPOLLERR, but return EPOLLIN | EPOLLRDNORM. Fixes: 1698a7f151126 ("media: v4l2-mem2mem: simplify poll logic") Signed-off-by: Ming Qian Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/v4l2-core/v4l2-mem2mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c index 675e22895ebe..094e1815209b 100644 --- a/drivers/media/v4l2-core/v4l2-mem2mem.c +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c @@ -924,7 +924,7 @@ static __poll_t v4l2_m2m_poll_for_data(struct file *file, if ((!src_q->streaming || src_q->error || list_empty(&src_q->queued_list)) && (!dst_q->streaming || dst_q->error || - list_empty(&dst_q->queued_list))) + (list_empty(&dst_q->queued_list) && !dst_q->last_buffer_dequeued))) return EPOLLERR; spin_lock_irqsave(&src_q->done_lock, flags); -- 2.35.1