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 356B9415F0C; Tue, 21 Jul 2026 22:55:29 +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=1784674531; cv=none; b=LgAVfbzXtjR/l/htLP+IRn9TprKKQYxb/rxGESwSURnS1VKsgP82VyRtMIu1WSiyNGIBsVPNZuYjj9lAzq3ch5prpRecqOGuH+FLn5HHseq2ckzNjRf+41ka7UArvEihWpRiPkvs+niUYjrK10x9QZBNWY/vMY/V78V0Nv1c0zE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784674531; c=relaxed/simple; bh=naAw2lHS2v1HqoGGqHWHeA6+NN3N7iqTXH3eK7Jbs/Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E3cav3bGR3hmbHKztdr9wEJRLbhirFodqKXL+ja2/ie2gQOUuSJja3kMvC3HJPTSmZNcfPcKanyPrb55w7Z1YjZP0UMWoIrkmO8Ch6fCiZ3ejPUKNIJQoIJ+64Ox1EmUFX/UrFciAFjwGGNlrjYNH3LXhCTKZ7I/agADqVUwApE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=IUliBfvI; 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="IUliBfvI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5756B1F000E9; Tue, 21 Jul 2026 22:55:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784674529; bh=J/gH7/+Ny2+bNQNVKRaPTFJlPJvLroBwZBvDhEA/UQ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IUliBfvIu6TCQ3AdovnPYmDSt3EV/2GtYH5jnxgp8OWnKSjg2aePM8cJzDzBaJGvv t4xFANWd129LOfIrBZ0SFRtIImR0qfjln3uweVZPhuReHuSnCM++Pfd9ivWQFJ0Xs7 9YNiNasPrwbU65KwfXbeQWjNVvMGgS0TDSOlWSjE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Vladimir Zapolskiy , Pengpeng Hou , Miquel Raynal Subject: [PATCH 5.10 575/699] mtd: rawnand: lpc32xx_mlc: fail DMA transfers on timeout Date: Tue, 21 Jul 2026 17:25:34 +0200 Message-ID: <20260721152408.679861562@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152355.667394603@linuxfoundation.org> References: <20260721152355.667394603@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.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Pengpeng Hou commit dbf590b662695b16fbf5917ef129697be4410ea9 upstream. lpc32xx_xmit_dma() starts a DMA transfer and waits up to one second for its completion, but it ignores the wait result and returns success after unmapping the buffer. A timed out read can therefore return success with incomplete data, and a timed out write can continue the NAND operation without proof that the DMA payload reached the controller. Terminate the DMA channel on timeout, unmap the scatterlist through the existing cleanup path, and return -ETIMEDOUT to the NAND read/write callers. Initialize the shared cleanup-path result before using it for dmaengine_prep_slave_sg() failures. Fixes: 70f7cb78ec53 ("mtd: add LPC32xx MLC NAND driver") Cc: stable@vger.kernel.org Reviewed-by: Vladimir Zapolskiy Signed-off-by: Pengpeng Hou Signed-off-by: Miquel Raynal Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/nand/raw/lpc32xx_mlc.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) --- a/drivers/mtd/nand/raw/lpc32xx_mlc.c +++ b/drivers/mtd/nand/raw/lpc32xx_mlc.c @@ -397,6 +397,7 @@ static int lpc32xx_xmit_dma(struct mtd_i struct lpc32xx_nand_host *host = nand_get_controller_data(chip); struct dma_async_tx_descriptor *desc; int flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT; + unsigned long time_left; int res; sg_init_one(&host->sgl, mem, len); @@ -411,6 +412,7 @@ static int lpc32xx_xmit_dma(struct mtd_i flags); if (!desc) { dev_err(mtd->dev.parent, "Failed to prepare slave sg\n"); + res = -ENXIO; goto out1; } @@ -421,7 +423,13 @@ static int lpc32xx_xmit_dma(struct mtd_i dmaengine_submit(desc); dma_async_issue_pending(host->dma_chan); - wait_for_completion_timeout(&host->comp_dma, msecs_to_jiffies(1000)); + time_left = wait_for_completion_timeout(&host->comp_dma, + msecs_to_jiffies(1000)); + if (!time_left) { + dmaengine_terminate_sync(host->dma_chan); + res = -ETIMEDOUT; + goto out1; + } dma_unmap_sg(host->dma_chan->device->dev, &host->sgl, 1, DMA_BIDIRECTIONAL); @@ -429,7 +437,7 @@ static int lpc32xx_xmit_dma(struct mtd_i out1: dma_unmap_sg(host->dma_chan->device->dev, &host->sgl, 1, DMA_BIDIRECTIONAL); - return -ENXIO; + return res; } static int lpc32xx_read_page(struct nand_chip *chip, uint8_t *buf,