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 BF19D314D1D; Wed, 3 Dec 2025 15:42:26 +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=1764776546; cv=none; b=DXyNm2FJSSsuGYgTocc6zDRSBBeAp1T88sgqgo99EYjRmzeq8GbqMq8VmidfeJBVkwe/PIVLRBzxzBuAsxh4z3BjV83lfWKkFnezyxoNNDmiSWEtcuDUMledGswbhn42NcGaYSFVyaa81MfPABFhAq1VT2wF/roDWxlR6yezoTY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764776546; c=relaxed/simple; bh=Rjw89wuSP60U5nPyeg+RBfyMeWDDLNqzSzcC97ijFIo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QdmVvFxCP6mU/ILGBkb1cXH8aWBKYGM3pYG4FKY9eEZp7egkdJgJrowxdP2CmxyVRaW2vy3tlb0zrm9VjolipoSqT300H35SilAPBvvaTSeO+Mpl/Lia4JaNQ10si4jUJFgmFLiltC8Zj4PyaOEnicnMSs6FgLxqfYVuMAA2vzo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=KjVLgux8; 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="KjVLgux8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E1D5C116C6; Wed, 3 Dec 2025 15:42:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1764776546; bh=Rjw89wuSP60U5nPyeg+RBfyMeWDDLNqzSzcC97ijFIo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KjVLgux8+TyvBqOHxtyUr0384TyqgAf7zEQfvRI5g1gnEcfK7JbvwJDeGEO/spUFP IsUCTnbchlQ/QBR5leS4g3jPVJQjcfuPdu9KniRzir6vvLNsL1ALlnhpJnJ5YbAmEG M0P46jH49lqDS2QHaM90uaSp5lXRGmWWgQogsYXQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Niravkumar L Rabara , Miquel Raynal Subject: [PATCH 5.10 216/300] mtd: rawnand: cadence: fix DMA device NULL pointer dereference Date: Wed, 3 Dec 2025 16:27:00 +0100 Message-ID: <20251203152408.625019896@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251203152400.447697997@linuxfoundation.org> References: <20251203152400.447697997@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: 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 @@ -2833,7 +2833,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, @@ -2877,6 +2877,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);