Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1876935rwb; Fri, 19 Aug 2022 10:54:38 -0700 (PDT) X-Google-Smtp-Source: AA6agR6zRr1xFRhhIqyxkbLReV/GqufXBKP6B7jDOvjAfFKKryCJLX2IBNFcMCIvrO7c+vCM0sjK X-Received: by 2002:a17:906:9b95:b0:733:5e1:b9a2 with SMTP id dd21-20020a1709069b9500b0073305e1b9a2mr5574204ejc.130.1660931677998; Fri, 19 Aug 2022 10:54:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660931677; cv=none; d=google.com; s=arc-20160816; b=RCXe+qnudDtQyg6Flhd2B7l2L9nXLCZJSSVPLMuhQRB8C3Y6sJagLyW6Mo/ohOyx+e GULaIhD4bQvsyG2gN0kIXOPd7QDFC+c2HD5ayNYM4Sha4M5RaxTAahW0LCTPjBem7SqI Y0+SSw2sWIoEszRB2manX92ewMw4FQlMh+31Jlp16zJTtd5ljEx62Uni8MZIv8PGw1bn HKcC+P6OpfTjndacq0VZJIWT5bhvzV7qYYDBTOXIRLBDsXkrEA7Vaz+sQLbPfA3Bm1V9 JPx2bnmKA3lUMQBt+0N1KMqcLBXoV3p78m6pEaH5Zd/ntlhfddhMJc6r1zIpLBEoeXnY m/qA== 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=k+IXogW0N+irdhfqH1BIUzHGhL5CFl2abirUfmksPzo=; b=QPw78A01ByHZ2OXJTPIRKB7+q+Sgefe2LdJsHterX8CQy8zaKFgoIrAdcWZGKyV9xW dxEHp2S+NcgnOxv0QHY4OyTsmOT74S51haU6x2+u5wH7wDKFVejIGPlL01ecGLa2jhCM +WEDY7Mb9ELHOhgHhD8G9kcK4dtthg1snE5Ks+p7Dj0NdD6UroEf8xR4o43EDo0x4dP2 /uedg6gt72zG3VXMCx3Q+5bFdDwGBf+InsVU6kBR2Akbe3ZZJuxPogts3mXc4hpBIzrU 8iobtpwSiCk39tcxxRObPb2VjAYEGAQGGJXyuxfIXX5SvUlF/5Lb5kzRCLqCLDDdKLU1 M3ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zaM5OKe7; 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 o9-20020a50c909000000b004409963eb80si2968982edh.432.2022.08.19.10.54.12; Fri, 19 Aug 2022 10:54:37 -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=zaM5OKe7; 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 S1351819AbiHSQKk (ORCPT + 99 others); Fri, 19 Aug 2022 12:10:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351482AbiHSQHx (ORCPT ); Fri, 19 Aug 2022 12:07:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13260BEF; Fri, 19 Aug 2022 08:56:25 -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 A2F3C614FE; Fri, 19 Aug 2022 15:56:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD22AC433D6; Fri, 19 Aug 2022 15:56:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660924584; bh=d8j1nbTfp0PG1P5kmBufL+4eKxvimt3iX2/2y6CVSSQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zaM5OKe7Mm+ILZ98D0W5MIA0YxybTUmeMSGMgJLhus/R9m6JWx2r5En8JPny2S+79 8ri2wKE4WXT4/SoTg+5fjQo4iHvqQW0itUmVYkN7RX1jQwoDd5JavnC/pTlGAsOZI6 tdv8pZeUTySq2ljGgBT2p/RTQmgBsVGm/ciowfy4= 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.10 187/545] media: v4l2-mem2mem: prevent pollerr when last_buffer_dequeued is set Date: Fri, 19 Aug 2022 17:39:17 +0200 Message-Id: <20220819153837.735940347@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@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 73190652c267..ad14d5214106 100644 --- a/drivers/media/v4l2-core/v4l2-mem2mem.c +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c @@ -927,7 +927,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