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 B76924E77FD; Wed, 30 Sep 2026 17:17:02 +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=1790788623; cv=none; b=BAjDoGNwzYZdPO8ZZS6T2QthE3QCnYQGSafbZg0Mp8gYHI36uvJp+JdkxJNe/F9Vw03yRIaysNPw5xA/KqsomZaXyhS+p4bVU3BTvbUfnaw8T8eGK/MJ1tXQGX9c4wj/vxGM+7cplwqGzu00pvhYRYTaO49dkeoNmuipbwh4nxY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790788623; c=relaxed/simple; bh=nA41bJQ1NKbEAb9x33n7g9zLqC1BcJRxOADdYu4L3jU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=m8+0akbZ8cyg1rfgh5zYIYo2+T5/d+w8zdU18YUOo1mb7L980N8fx0XeJP9zdSVFII6Z9kmJzD9Hqvep9cCDyEFKLSitPvN6mpqQFwzUcEnCXmtTjNbsyqxzabzXMV/tsoylkS/tHd/P0p7olMfPAmk6M5T5he4Q5NyDPM7SilM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=WbBvZvnq; 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="WbBvZvnq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 492381F000FF; Wed, 30 Sep 2026 17:17:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790788622; bh=3aAsskv95QEYz4aAX3OvvLg6UiQSbTQgUk1p6j58m00=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WbBvZvnq3VXcYRkUHmdwFufi36/4TXhliNM1GqYR/+xGWG+EWaykDsDEPIz3IkyCe TAAoSFCk+xrqBm04tgpEJcCfwQu3g6p0NqI3gycsO2XynZ/OVhL5jWLGYWcNshrPTa UXSwRIlLDybUXljdhnqXBmYlhM37HHm0oqXoviIM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Christian Lugnberg , Frank Li , Vinod Koul Subject: [PATCH 6.12 189/877] dmaengine: sun6i: fix undefined behaviour in sun6i_dma_tx_status Date: Wed, 30 Sep 2026 17:18:20 +0200 Message-ID: <20260930152418.805534961@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152414.738996857@linuxfoundation.org> References: <20260930152414.738996857@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.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Christian Lugnberg commit 9096bdc8d930147f7c39a493a859acbd3a8485d8 upstream. sun6i_dma_tx_status() calls vchan_find_desc() to look up the virtual descriptor for a given cookie, before checking whether the pointer vd is NULL: vd = vchan_find_desc(&vchan->vc, cookie); txd = to_sun6i_desc(&vd->tx); /* vd may be NULL here */ if (vd) { for (lli = txd->v_lli; ...) vchan_find_desc() returns NULL when the descriptor has already been completed or is in-flight on a physical channel and no longer present in the virtual channel's descriptor list. When vd is NULL, to_sun6i_desc() is called unconditionally on &vd->tx before the NULL check, which is undefined behaviour. Move the call inside the if (vd) guard to ensure it is only reached with a valid pointer. vd = vchan_find_desc(&vchan->vc, cookie); if (vd) { struct sun6i_desc *txd = to_sun6i_desc(&vd->tx); for (lli = txd->v_lli; ...) Fixes: 555859308723 ("dmaengine: sun6i: Add driver for the Allwinner A31 DMA controller") Cc: stable@vger.kernel.org Assisted-by: Claude:claude-sonnet-4-6 Signed-off-by: Christian Lugnberg Reviewed-by: Frank Li Link: https://patch.msgid.link/20260817135723.12807-3-christian.lugnberg@soundtrack.io Signed-off-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman --- drivers/dma/sun6i-dma.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/drivers/dma/sun6i-dma.c +++ b/drivers/dma/sun6i-dma.c @@ -970,7 +970,6 @@ static enum dma_status sun6i_dma_tx_stat struct sun6i_pchan *pchan = vchan->phy; struct sun6i_dma_lli *lli; struct virt_dma_desc *vd; - struct sun6i_desc *txd; enum dma_status ret; unsigned long flags; size_t bytes = 0; @@ -982,9 +981,9 @@ static enum dma_status sun6i_dma_tx_stat spin_lock_irqsave(&vchan->vc.lock, flags); vd = vchan_find_desc(&vchan->vc, cookie); - txd = to_sun6i_desc(&vd->tx); if (vd) { + struct sun6i_desc *txd = to_sun6i_desc(&vd->tx); for (lli = txd->v_lli; lli != NULL; lli = lli->v_lli_next) bytes += lli->len; } else if (!pchan || !pchan->desc) {