From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C6D1F35BDB9; Wed, 3 Dec 2025 16:41:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764780120; cv=none; b=SBb3Kcpj43FKWEGVutrqDPj/XWvFMskrnY4yP7SdjQGtYP4KsWJG/IqKMlkFDwu6GYf8PO0wq98qj/tbvvvumEZc0XhO9hU1+8lMTEX4/rrgS6+X2G7v54WWUA+t0QA9/tPsubkJOBAFFB919aO+6nMt6YEm1VSYEQvSjmXNPBE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764780120; c=relaxed/simple; bh=77JRD8mF3R0KfzRbaMegHwkJgVdVnyC2SjsvkuNmGhQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T2ppnUjpc76ELcppj5M5feyX1CJKZd7SnN1uiIVKMxaKeVv0CN9yAWicMjT9LuYqzHxwAV0Sg8I59DUtU9QgOae+zDu9T/11+DHkJPml63VpjIomWzndA6lrK5H527SR8fOqTWNrR6zLPIgDVV5bglUeP/3PnLvwK3rg/cmIAok= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=dvVLQz7m; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="dvVLQz7m" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 302DEC4CEF5; Wed, 3 Dec 2025 16:41:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1764780119; bh=77JRD8mF3R0KfzRbaMegHwkJgVdVnyC2SjsvkuNmGhQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dvVLQz7mnNXaObXapFlouiiAR80QQsdXmcK2m/3Ys2KgFb+NktmTAVIM2uELRtg2h lSYZUnE280VZPPZg6RcK4fjiRhGC6MD48zQXE/6+1eqo1CzQaEkI0j/45Yg0pv8bma hxbdUTmYyD+JtVJ3PrhEGFZF7Y+rmWL6iunCXI6U= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Niravkumar L Rabara , Miquel Raynal Subject: [PATCH 6.1 429/568] mtd: rawnand: cadence: fix DMA device NULL pointer dereference Date: Wed, 3 Dec 2025 16:27:11 +0100 Message-ID: <20251203152456.407410297@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251203152440.645416925@linuxfoundation.org> References: <20251203152440.645416925@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.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Niravkumar L Rabara commit 5c56bf214af85ca042bf97f8584aab2151035840 upstream. The DMA device pointer `dma_dev` was being dereferenced before ensuring that `cdns_ctrl->dmac` is properly initialized. Move the assignment of `dma_dev` after successfully acquiring the DMA channel to ensure the pointer is valid before use. Fixes: d76d22b5096c ("mtd: rawnand: cadence: use dma_map_resource for sdma address") Cc: stable@vger.kernel.org Signed-off-by: Niravkumar L Rabara Signed-off-by: Miquel Raynal Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/nand/raw/cadence-nand-controller.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/mtd/nand/raw/cadence-nand-controller.c +++ b/drivers/mtd/nand/raw/cadence-nand-controller.c @@ -2830,7 +2830,7 @@ cadence_nand_irq_cleanup(int irqnum, str static int cadence_nand_init(struct cdns_nand_ctrl *cdns_ctrl) { dma_cap_mask_t mask; - struct dma_device *dma_dev = cdns_ctrl->dmac->device; + struct dma_device *dma_dev; int ret; cdns_ctrl->cdma_desc = dma_alloc_coherent(cdns_ctrl->dev, @@ -2874,6 +2874,7 @@ static int cadence_nand_init(struct cdns } } + dma_dev = cdns_ctrl->dmac->device; cdns_ctrl->io.iova_dma = dma_map_resource(dma_dev->dev, cdns_ctrl->io.dma, cdns_ctrl->io.size, DMA_BIDIRECTIONAL, 0);