From nobody Thu Oct 9 20:25:21 2025 Received: from ssh247.corpemail.net (ssh247.corpemail.net [210.51.61.247]) (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 3BFB71DDC23; Mon, 16 Jun 2025 10:44:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.51.61.247 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750070672; cv=none; b=o3kPOsJVtUc2GdhGQPsWozhaLliXyL2e0X9+H47hvXN02pbXCkp8rAZPbvCNCV4DWwxm+iadKOKENSFmnjbWWkiw/N+5R/of39moC4wxwDZtJ6bDAOsf4kd41uUjqmZlXzO8FsC3hfydCGqrcDPtq72zXxDiHal3dtx9IfkeNH4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750070672; c=relaxed/simple; bh=LgglmT9a5i4f+e3Hdc2uHkjad54ebIatzamizH+LMFE=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=Ob19OYCEYimNqA2cakBBJFPFTSqYxsPakCDp75ZE6yFHxAwWryo2OJE+4KccqZOSSAZHPj35JCnx1qXm/z+ur5XecmQ3Maqz4MXZ10qFcPVEf0A9j9nJiZIF6uAWYtU8hi0tXl0tymCFgZAHakTWzybQ7+/rGj7RDU9d1jwklIY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=inspur.com; spf=pass smtp.mailfrom=inspur.com; arc=none smtp.client-ip=210.51.61.247 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=inspur.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=inspur.com Received: from jtjnmail201609.home.langchao.com by ssh247.corpemail.net ((D)) with ASMTP (SSL) id 202506161844237586; Mon, 16 Jun 2025 18:44:23 +0800 Received: from locahost.localdomain.com (10.94.7.47) by jtjnmail201609.home.langchao.com (10.100.2.9) with Microsoft SMTP Server id 15.1.2507.57; Mon, 16 Jun 2025 18:44:22 +0800 From: Charles Han To: , , , CC: , , , Charles Han Subject: [PATCH V2] dmaengine: Add NULL check in lpc18xx_dmamux_reserve() Date: Mon, 16 Jun 2025 18:44:19 +0800 Message-ID: <20250616104420.1720-1-hanchunchao@inspur.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable tUid: 2025616184423c1b5f9bdf3a34ef1958d2b3d4c38fecf X-Abuse-Reports-To: service@corp-email.com Abuse-Reports-To: service@corp-email.com X-Complaints-To: service@corp-email.com X-Report-Abuse-To: service@corp-email.com Content-Type: text/plain; charset="utf-8" The function of_find_device_by_node() may return NULL if the device node is not found or CONFIG_OF not defined. Add check whether the return value is NULL and set the error code to be returned as -ENODEV. Fixes: e5f4ae84be74 ("dmaengine: add driver for lpc18xx dmamux") Signed-off-by: Charles Han --- drivers/dma/lpc18xx-dmamux.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/dma/lpc18xx-dmamux.c b/drivers/dma/lpc18xx-dmamux.c index 2b6436f4b193..f61183a1d0ba 100644 --- a/drivers/dma/lpc18xx-dmamux.c +++ b/drivers/dma/lpc18xx-dmamux.c @@ -53,11 +53,17 @@ static void lpc18xx_dmamux_free(struct device *dev, voi= d *route_data) static void *lpc18xx_dmamux_reserve(struct of_phandle_args *dma_spec, struct of_dma *ofdma) { - struct platform_device *pdev =3D of_find_device_by_node(ofdma->of_node); - struct lpc18xx_dmamux_data *dmamux =3D platform_get_drvdata(pdev); + struct platform_device *pdev; + struct lpc18xx_dmamux_data *dmamux; unsigned long flags; unsigned mux; =20 + pdev =3D of_find_device_by_node(ofdma->of_node); + if (!pdev) + return ERR_PTR(-ENODEV); + + dmamux =3D platform_get_drvdata(pdev); + if (dma_spec->args_count !=3D 3) { dev_err(&pdev->dev, "invalid number of dma mux args\n"); return ERR_PTR(-EINVAL); --=20 2.43.0