From patchwork Tue Jun 11 09:22:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacky Huang X-Patchwork-Id: 13693351 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 27CE0C25B76 for ; Tue, 11 Jun 2024 09:23:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=N7SvquZFcEovLWrBfZPAsERkCyRXy9ODqVWHtjwMmTU=; b=uVZEAABFzqb1Pm i/E+ABjTJkBV9nzTP+aqd7fktRfDfujRKnrDRUImL/ZqN83g2T/SF0YGzyVY9lDIyZ9XY9EbhMyHe izlH3Y6GfN8pa9oD3lrVf1jfetw0Ow9JqFgL8of+FZw5Le5fvPBCNb4GP3eeAKefdnF2lC6VjFBPr MocsxodgyQ6SqYi2hKUHNYHBE6518hk8CbJ8qDQq/IVMriA8p8gA5ZeTkeJtaMR81wrotJHRQF6Rt HT8XmcAlqPCIqGobwV+DXqiBfux49jwaSnS4ThDUATgnNE7/AygNOIMtLCCpYE+o88bTUC+DSpWZa fPNgL8bAdqzOd97wWshA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sGxiZ-00000008H7Y-23qh; Tue, 11 Jun 2024 09:23:03 +0000 Received: from mail-oa1-x32.google.com ([2001:4860:4864:20::32]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sGxiW-00000008H6e-1NMB for linux-arm-kernel@lists.infradead.org; Tue, 11 Jun 2024 09:23:01 +0000 Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-2547e1c7bbeso1851146fac.2 for ; Tue, 11 Jun 2024 02:22:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718097776; x=1718702576; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=OsSZjJYi2Nx5uLL2KWMNdlU8KMn1DODUxTte5l/ndgg=; b=CY6lsanyJm45uzUNW+u0MIdfUXXPwhyah+pXzmVp/j+AjQbZqNnLefErjI88WHF9aU /2mb8hiTiv+1G1wDd2tw1uPkX1hRiZPgrr2iFDtjENalICGLt+pGc8vqfBG+oEk44Z3K E6af/xI3jBpL2gRD6jI/CG7zZ4ZqHcmdWCaV7J1PlIXOpobkwrgeTDDe3em684f3Xcjt CzuaZXXBaSkqDxPrAR6IPHEWxxvrhaam2y7ZPPjAnnRPPtvMnRksJ8OPc3VJA921U1fu BeXF1BlANJ1d6Vb8XLmZy+LMUvha6t5JtNQJme+/EuHHFvj6qExxE+gjp6M6XwBflmpD +deA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718097776; x=1718702576; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=OsSZjJYi2Nx5uLL2KWMNdlU8KMn1DODUxTte5l/ndgg=; b=N1x7cUeu274lD26Dl/PNYUeY8Kjo2G0fyxlZfNs9AMfCo0UDVtGEdllLX1OqQDOPqY 5yVdVc9to+7719qOTygTJ3M1pqQOzsasHuu4EwCdUWlx7CGXSG4GWgw85rkdxHHQJ6O1 2RVzCqwVaN0EoP4PbiRfOr5rInkOoYH7/A6DQB1BuXJRJobhiVowvdFtiDASn10UXiGK l2SkRBWC07EesNUpD7BM/emHcr66Nv6gc4lHDThURt8cwa6uHayAaQhQOQPrejJLlYmv P80qEoIhiC8AIzPM+MuhsJ7qfcivFt9NCh0l6HjoBtAikOPqkvAbjdUOiQFC9V57FKkS 090w== X-Gm-Message-State: AOJu0Yyp6F8eB6UyY6P53yR2TyLoA/cZS55aq+/yfQddKFXx0HhyGbAw i2NpiRT8gc1Az8Ft4m8YGTutZq2pceqqR1ccKvqHu/od+nW0E+OH X-Google-Smtp-Source: AGHT+IEyG+pk/FChVcVFXKGDVLPcTkGKCczl4p5GmwV4XsFl+Q0rny6LJy1/Ao8UHHkuMx0DRQFj6A== X-Received: by 2002:a05:6870:f144:b0:250:67c4:d73c with SMTP id 586e51a60fabf-25464ccb42amr12664378fac.28.1718097776235; Tue, 11 Jun 2024 02:22:56 -0700 (PDT) Received: from a28aa0606c51.. (60-250-192-107.hinet-ip.hinet.net. [60.250.192.107]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7041043b2a5sm6904949b3a.148.2024.06.11.02.22.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 02:22:55 -0700 (PDT) From: Jacky Huang To: dan.carpenter@linaro.org, gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Jacky Huang Subject: [PATCH] tty: serial: ma35d1: Add a NULL check for of_node Date: Tue, 11 Jun 2024 09:22:51 +0000 Message-Id: <20240611092251.159149-1-ychuang570808@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240611_022300_413271_CD6083F4 X-CRM114-Status: GOOD ( 14.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Jacky Huang The pdev->dev.of_node can be NULL if the "serial" node is absent. Add a NULL check to return an error in such cases. Signed-off-by: Jacky Huang --- drivers/tty/serial/ma35d1_serial.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/tty/serial/ma35d1_serial.c b/drivers/tty/serial/ma35d1_serial.c index 19f0a305cc43..3b4206e815fe 100644 --- a/drivers/tty/serial/ma35d1_serial.c +++ b/drivers/tty/serial/ma35d1_serial.c @@ -688,12 +688,13 @@ static int ma35d1serial_probe(struct platform_device *pdev) struct uart_ma35d1_port *up; int ret = 0; - if (pdev->dev.of_node) { - ret = of_alias_get_id(pdev->dev.of_node, "serial"); - if (ret < 0) { - dev_err(&pdev->dev, "failed to get alias/pdev id, errno %d\n", ret); - return ret; - } + if (!pdev->dev.of_node) + return -ENODEV; + + ret = of_alias_get_id(pdev->dev.of_node, "serial"); + if (ret < 0) { + dev_err(&pdev->dev, "failed to get alias/pdev id, errno %d\n", ret); + return ret; } up = &ma35d1serial_ports[ret]; up->port.line = ret;