From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B16937A494; Thu, 30 Jul 2026 16:07:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785427671; cv=none; b=j93BI6f9UDTn5JpxvNvX44OiIWtsf5JRIzRZFCcYF8WR4KlyWYwvu3QmSEPs7ybLxjVNxFJWQlgc8FIyLc8y2D9bts1X6iSDkE/btrJ/JbEerRjlGAQnddwb+r03pcWC6BJAMDZZNFIqriJqtI9Auw+pomstNYgPLuRe2o0o478= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785427671; c=relaxed/simple; bh=keXMFthYaheBNFoC8v1tlqD7VJt0AKEpu6DFMqEnUxo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DS++HGqOiUewMr4A37HD1q18Ad9BccKraxO6xcQdARgOtOIh7Ded+KH2cSuDcgKbRORvq5ifhVi1i86tyQvA5QAyf/YY6QtJU2DDBQQ5nY0GrM25yaMNhJZ6OSjSIkP7zg+p/XGqp9AD5pkOkpL3scmqx5CsHyUS7VtokB1Sl7g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=P/2i/fCP; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="P/2i/fCP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 875F11F000E9; Thu, 30 Jul 2026 16:07:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1785427670; bh=ZhJ47h5Pi+wM76fIjeJZ2lzlxmPYquTEAe42E1+SoNA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=P/2i/fCPQqLc9ea/BzRCxEsKVEAjHCOjDFVo/ySXLVn+VmJVzfn9fKVuSCeo2btQB E2ituDyjeFWyFCpgAOCjEWp7Oespu+3v3cEHX1qSA43Jkg0PXclfB0sERalLgh6bQJ J9HYKptNc6+Ng25OWNlKxGm7Q+84rUuhaO2LPsJw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Valery Borovsky , Hans Verkuil Subject: [PATCH 6.6 252/484] media: pwc: Return queued buffers on start_streaming() failure Date: Thu, 30 Jul 2026 16:12:29 +0200 Message-ID: <20260730141428.963080300@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260730141423.392222816@linuxfoundation.org> References: <20260730141423.392222816@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Valery Borovsky commit 975b2ee20e569d47821e4f6c9761b4664d48a6a4 upstream. The vb2 framework hands buffers to the driver via buf_queue() before calling start_streaming(). If start_streaming() returns an error without first returning those buffers via vb2_buffer_done(), vb2_start_streaming() fires WARN_ON(owned_by_drv_count) and the queued buffers leak. pwc's start_streaming() had two early returns that hit this trap: -ENODEV when the USB device was already disconnected, and -ERESTARTSYS when mutex_lock_interruptible() was interrupted by a signal. Call the existing pwc_cleanup_queued_bufs() helper with VB2_BUF_STATE_QUEUED before returning (matching the state already used by the pwc_isoc_init() error path in the same function). This mirrors the uvcvideo fix in commit 4cf3b6fd54eb ("media: uvcvideo: Return queued buffers on start_streaming() failure"). Fixes: ceede9fa8939 ("[media] pwc: Fix locking") Cc: stable@vger.kernel.org Signed-off-by: Valery Borovsky Signed-off-by: Hans Verkuil Signed-off-by: Greg Kroah-Hartman --- drivers/media/usb/pwc/pwc-if.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/drivers/media/usb/pwc/pwc-if.c +++ b/drivers/media/usb/pwc/pwc-if.c @@ -711,11 +711,15 @@ static int start_streaming(struct vb2_qu struct pwc_device *pdev = vb2_get_drv_priv(vq); int r; - if (!pdev->udev) + if (!pdev->udev) { + pwc_cleanup_queued_bufs(pdev, VB2_BUF_STATE_QUEUED); return -ENODEV; + } - if (mutex_lock_interruptible(&pdev->v4l2_lock)) + if (mutex_lock_interruptible(&pdev->v4l2_lock)) { + pwc_cleanup_queued_bufs(pdev, VB2_BUF_STATE_QUEUED); return -ERESTARTSYS; + } /* Turn on camera and set LEDS on */ pwc_camera_power(pdev, 1); pwc_set_leds(pdev, leds[0], leds[1]);