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 5F0E6421225; Mon, 17 Aug 2026 14:29:43 +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=1786976985; cv=none; b=PNvodEGgKMa+mpv1zRr3umZFM/e+tQ5ayR+B1pyaKekuaOUTn73uabiAdj21K2BxW44cmJ85N/6VOFcmFdu3e86Vz/zbg70rb1Rz0M/ePDyn7ZzkLgJAj4FbFIE8Mqp1zXS3YXhrS4OP4ioOcjASQCWwOINrzzpxg9R7AcK0McQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786976985; c=relaxed/simple; bh=hQk4MaQpAAeQRHKG7UEg6SWSY7dVdKTRe2++05Q+yJ8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gGXSOMs2C2Ncc9zqG+kpSnQrhWgiRHBih8blWfcc03tCFcvqRzSSk47JGWEYlxNUHW4nBeiBCYV84Q4SzzbsUQjsmeGDrsrabWUkURcOzBTbmZcmfcGnQEk6SYsduoN3FuImSIJUEr/lCQWqnZRjbsF0uzL+PdVvQI2FomqAxvQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=0i0/JZWh; 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="0i0/JZWh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95E3F1F000E9; Mon, 17 Aug 2026 14:29:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786976983; bh=Sl8kJwJBmHqJL5XKxdHu0Ubj8ONpZgl8cD2XyRx09ZQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=0i0/JZWhlXcs1r4N2Zk42QvwPa3OE0wLHo9yx5cGi3EFhxhUEelFtENk2w95lc6sb FNx6pd+J+bBxlVaenKLzIpzcoKUmcomEISWhq673sZZDjsLh92Md/HzSRxdNsXlyGZ BpmCbvBTUdV9PQqbhiDxb0/1qA1hJn6WCUFMcOak= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Valery Borovsky , Hans Verkuil Subject: [PATCH 5.15 171/456] media: sun4i-csi: Return queued buffers on start_streaming() failure Date: Mon, 17 Aug 2026 15:29:21 +0200 Message-ID: <20260817132546.801315036@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260817132539.792407575@linuxfoundation.org> References: <20260817132539.792407575@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 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Valery Borovsky commit bbba3e260a62810a717b4442a3bb96d0ec0f6309 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. sun4i_csi_start_streaming() returned -EINVAL when no matching CSI format could be found, before any setup (scratch buffer allocation, pipeline start) had been performed. The remaining error paths already converge on the err_clear_dma_queue label, which calls return_all_buffers(..., VB2_BUF_STATE_QUEUED) under csi->qlock. Jump to that label directly: the intermediate err_disable_device / err_disable_pipeline / err_free_scratch_buffer labels are skipped, which is correct because nothing they would undo has happened yet. This mirrors the uvcvideo fix in commit 4cf3b6fd54eb ("media: uvcvideo: Return queued buffers on start_streaming() failure"). Fixes: 577bbf23b758 ("media: sunxi: Add A10 CSI driver") Cc: stable@vger.kernel.org Signed-off-by: Valery Borovsky Signed-off-by: Hans Verkuil Signed-off-by: Greg Kroah-Hartman --- drivers/media/platform/sunxi/sun4i-csi/sun4i_dma.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/media/platform/sunxi/sun4i-csi/sun4i_dma.c +++ b/drivers/media/platform/sunxi/sun4i-csi/sun4i_dma.c @@ -234,8 +234,10 @@ static int sun4i_csi_start_streaming(str int ret; csi_fmt = sun4i_csi_find_format(&csi->fmt.pixelformat, NULL); - if (!csi_fmt) - return -EINVAL; + if (!csi_fmt) { + ret = -EINVAL; + goto err_clear_dma_queue; + } dev_dbg(csi->dev, "Starting capture\n");