Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3088344rwb; Mon, 15 Aug 2022 17:50:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR6+rnxPT+5W8fXMijuvSysmZ6WpyH/dQExwO3hhaXx4MLGlKraRZaFRZkVIbTjI5Jhqcgxp X-Received: by 2002:a17:907:2672:b0:734:a952:439a with SMTP id ci18-20020a170907267200b00734a952439amr11523933ejc.539.1660611040386; Mon, 15 Aug 2022 17:50:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660611040; cv=none; d=google.com; s=arc-20160816; b=o/x1FIldHd7G3f66u4MF3ndobEWVfi2tCqMYCNFErpIt8Z4tSbmQYSdBbLzMyygEKN mIcAnJtMAfY2G+G9QZBrGk+Hv0pK5z7f/gvuHZCPD5QMwJUD9ZLS/D/x33dKMuF7C+sf 7PAz42O8SfKUDy0jghAZFQ1Ny3INiKR9fSfgPgTzTzzX77d5zt38L0rVgsJGmicqRidO zU5SwL1HpWqfI+sw7jhFfHDMAQKwB72ZVTzi6P2ghTlIdpdSVd1rvMl7nmwy+ET+C78P VfPiN4sT9iZmUi+esq0VCM0z8yI9Fqp4WpH9RqVHFhWCr7y/vlwbLOr0Uj58u85iK/7B tKkg== 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=dHbZw1o6h4Kw/dzGI6Ij7VZt3ZsLcmyyTl2u3uaR/wg=; b=Qf8qexebs9/JuKX4VFsyTcOXdh9U/zL0GqGin0J9MDmQln2hokx5xeogkPUscGlQUO WT9eCQK5hR5VVHSEQYPzcEbvPalDfqu+ETzEfgAy5ssOvKgHO2vns0I/BaP0L2stFF67 uMLHFCbuXcnAnl8vletQH29mfPfBa/xRubNJjC49DPRvymxMvfcy+C0Le1b6OlqKlnI+ zh7txdRBAmp+kGD2qbGLxmJPEvsuA6N8T5QjrvWMDTUDRISIcRlBx1KtyKNRpZPV86PI az4wD1eD+xPdEU2OKj1hNnG8CUmuthhVy0SF6ls3HVPGEYBAI7G/ME39mUPX7cc4NBOo 32Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RVRkhWpS; 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 z17-20020a05640240d100b0043e2017e819si9536780edb.22.2022.08.15.17.50.15; Mon, 15 Aug 2022 17:50:40 -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=RVRkhWpS; 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 S1354173AbiHOXnr (ORCPT + 99 others); Mon, 15 Aug 2022 19:43:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354111AbiHOXlT (ORCPT ); Mon, 15 Aug 2022 19:41:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 788097695A; Mon, 15 Aug 2022 13:10:39 -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 DFED460025; Mon, 15 Aug 2022 20:10:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BFA62C433D6; Mon, 15 Aug 2022 20:10:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660594238; bh=9l5a7uxFD4tC0+inbuqt5PluP2aZ1z05eFhVaLGUPFM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RVRkhWpS3+WeUdCq2PQFIVhnwTmpohAriwjhNiDHdTy2rJpyQNLqsoSbDiRIezGL7 YYqomH6snkImuW8Kl2WA8R3rvVfgMgUruxAOxQeAYTtJEjkTfWv02cbRQRQHDgJ8W5 WdyCjwECgX1/o5qdd5eGCdAf6K9WLK0LuRrXNuMo= 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.19 0399/1157] media: v4l2-mem2mem: prevent pollerr when last_buffer_dequeued is set Date: Mon, 15 Aug 2022 19:55:55 +0200 Message-Id: <20220815180455.630760694@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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 6469f9a25a4e..837e1855f94b 100644 --- a/drivers/media/v4l2-core/v4l2-mem2mem.c +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c @@ -925,7 +925,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