Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2878967rwb; Mon, 15 Aug 2022 13:10:05 -0700 (PDT) X-Google-Smtp-Source: AA6agR4uy5ytuFYaIW6nw3u8mZ2kx8hLRWrGXvH27jOOnsfE+BU0Y6wh6uB7RBnrs3tHscf5Y9YN X-Received: by 2002:a17:907:9710:b0:731:67b1:dc3b with SMTP id jg16-20020a170907971000b0073167b1dc3bmr11538490ejc.709.1660594205547; Mon, 15 Aug 2022 13:10:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660594205; cv=none; d=google.com; s=arc-20160816; b=WP373VOQDFfqs73G1B+LCeNITtE11F23LmIckwR203l0oluMwAjgY9onh6ZSWj2eWR Uf3MzcyXNNxfVti2TYK0xdFDgYYBT6gEDOPOjQkHFBrDLGAwT9i14Q9SRNBcGNdS4PkF eKMpSiJYjIPOuK0mhBzvK2SPTOqd0buVtaYW0bfeuUkT+Kyi9/+2YZh1oxswpcOy/+1x KmcBOJ51IPihjUWi3sJ58zoaCDvdrl6HrtmgiTaOTxLaI3XLVmmoBuIpW/DPTCkfixuS iNcRTi7rFmtMxcVvj/vg4DMBBKqdkxMBAZbruJOOGBuV9aBfSDnWjluiJhnWi+ofr4qk w+4g== 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=6XrIqxInBoIcnB4TqUF/bRtkZBRjSfHDaz+dCv/tGfg=; b=bj6luvS4o7MjEl5FXjfngrMFcmcowxVBAS1fDvXNss2i3GQvh9/lkhPZ58nhdYoDLu 8EmkM1p5Z5D89XgXQenmmO0boBD2nCed/F5doIcSCr2uiUUAxqFC+FTX+AKDGIm3NtrK LK5rG++jVqdMuS7DBBxEDcHfUxkQ7dPjnX6YRTfPPLpCnqD4nhGXsPB0/P84D6vIwnh/ MnHfgTBgnjdbyqK51GzHNjALO//wMuC4tByhg0IOcDpSPU4/p7WRFtoVwEZI8sR/7d55 znXebH6oPypycQx10VA2JvRwAos9S/uqXHYxETjmPG541ZzbwRENEZiD3MP9GB73z1nn q2OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=j71Rh768; 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 dr2-20020a170907720200b007262b057924si7738433ejc.900.2022.08.15.13.09.39; Mon, 15 Aug 2022 13:10:05 -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=j71Rh768; 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 S244418AbiHOSxp (ORCPT + 99 others); Mon, 15 Aug 2022 14:53:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244367AbiHOSvD (ORCPT ); Mon, 15 Aug 2022 14:51:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02D0E4507D; Mon, 15 Aug 2022 11:29:04 -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 524AC60FD0; Mon, 15 Aug 2022 18:29:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44D19C433C1; Mon, 15 Aug 2022 18:29:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660588142; bh=g1mk+vmcxktkc1t9tqPGfbG+JhLYSmNUrGkq/633Ips=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j71Rh768OTwCyr6TNZwL/R9cTbVeHuEIuXBaBVvfWonBd8YRdkUNlCiEKgrQjCVz/ slk6hSHGzOmvgjaz3D5SyuTkJq/TRd9PMioxWGdoEka8nNh7v4gptWPUXkXM9J4n4U 93Eyy4ZQRMJfAMuB60bRqy9DFSSWsjk+PkAroKIE= 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.15 291/779] media: v4l2-mem2mem: prevent pollerr when last_buffer_dequeued is set Date: Mon, 15 Aug 2022 19:58:55 +0200 Message-Id: <20220815180349.712391088@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@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 3de683b5e06d..8aeed39c415f 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