public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ma Ke <make24@iscas.ac.cn>
To: gregkh@linuxfoundation.org, jirislaby@kernel.org,
	make24@iscas.ac.cn, u.kleine-koenig@pengutronix.de,
	tglx@linutronix.de, zhang_shurong@foxmail.com,
	B56683@freescale.com, cosmin.stoica@nxp.com,
	stefan-gabriel.mirea@nxp.com, Larisa.Grigore@nxp.com,
	matthew.nunez@nxp.com
Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
	stable@vger.kernel.org
Subject: [PATCH] tty: serial: Add a NULL check for of_node
Date: Wed, 14 Aug 2024 18:15:20 +0800	[thread overview]
Message-ID: <20240814101520.17129-1-make24@iscas.ac.cn> (raw)

The pdev->dev.of_node can be NULL if the "serial" node is absent.
Add a NULL check for np to return an error in such cases.

Found by code review. Compile tested only.

Cc: stable@vger.kernel.org
Fixes: 09864c1cdf5c ("tty: serial: Add linflexuart driver for S32V234")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
---
 drivers/tty/serial/fsl_linflexuart.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/tty/serial/fsl_linflexuart.c b/drivers/tty/serial/fsl_linflexuart.c
index e972df4b188d..f46f3c21ee1b 100644
--- a/drivers/tty/serial/fsl_linflexuart.c
+++ b/drivers/tty/serial/fsl_linflexuart.c
@@ -811,6 +811,9 @@ static int linflex_probe(struct platform_device *pdev)
 	struct resource *res;
 	int ret;
 
+	if (!np)
+		return -ENODEV;
+
 	sport = devm_kzalloc(&pdev->dev, sizeof(*sport), GFP_KERNEL);
 	if (!sport)
 		return -ENOMEM;
-- 
2.25.1


             reply	other threads:[~2024-08-14 10:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-14 10:15 Ma Ke [this message]
2024-08-14 10:28 ` [PATCH] tty: serial: Add a NULL check for of_node Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240814101520.17129-1-make24@iscas.ac.cn \
    --to=make24@iscas.ac.cn \
    --cc=B56683@freescale.com \
    --cc=Larisa.Grigore@nxp.com \
    --cc=cosmin.stoica@nxp.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=matthew.nunez@nxp.com \
    --cc=stable@vger.kernel.org \
    --cc=stefan-gabriel.mirea@nxp.com \
    --cc=tglx@linutronix.de \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=zhang_shurong@foxmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox