Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp224255lqp; Tue, 11 Jun 2024 02:33:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUDIjN7//S7tz+o1lM4b9WHz265qYoldb3/1pnohRz/5PNmwe9cRHR3LLp1CYSEsgmjxZJ2U6XuWs47KItpAWbTMOuFYbA3IvDLl7WVjg== X-Google-Smtp-Source: AGHT+IFvRbpmFqfGO2ApJK4HAJSdLeAQ1SeDCCuaIH7NNJJEtH40llXUSuvZpRoOlv93WQsBLdZV X-Received: by 2002:a17:907:a43:b0:a6f:2203:93cd with SMTP id a640c23a62f3a-a6f2203a1bfmr345116566b.11.1718098403293; Tue, 11 Jun 2024 02:33:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718098403; cv=pass; d=google.com; s=arc-20160816; b=R0Bn4hFiTg1WsSfhYuyl4mOtRj7O7PWg1y8Z/qypqhrHl/m/O7dlCj7Dsgt57GOgfM PGKcNNjwdiH2sdL09VYKe/pVNfVNLgsVpjnGsBWugNyf9bSZ+gHm7rVEoFsYGjs+8kGV 6eMkTclpw8u8N8bmOY74tUhy+xKGIReT3Cld4xadMPc81JtRahFMgzBh24CxxH5NHqvX Fl478aNkE3DnGD9lr0xsR5GvQCTo1NAWAQh+coNyC+5s4/IlZKMjSbyZVJjRcTpsrZW+ NXKdM/z76KBjHFKxSg3JfqRSN0DgcxtHqQXoU5utusLc/W5Wo5Gq/LZtwwlQarsV2uYI sL1Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=OsSZjJYi2Nx5uLL2KWMNdlU8KMn1DODUxTte5l/ndgg=; fh=0kGzuaU1ldLltUx8W6UKpkC8CxxhOu7q3FuRM/JcOLQ=; b=C/2DPBdCb6Q4xyN0DQeTUqrZe2SahWgCcY6IRTHQ6VLfgIPzUXeAxwdlVDcid9aycZ /5hXJ7MCnHPpMUNXlYhUceCVz6tFqioQUvmJVJYK20dX9nWuIji6Rg/ESBe257rFbpCe LFmpzQY8Gn2OqCKIRpadSxFNoj1LF+6P5l9XG+kYI39QX8LpyrLeXlcXEGHOj0+9kGlm noGWNiBm24aVWQfmBFuwKQorNMjh5WzdYE+A9bkHasgFkVkut9R0B1CCC/odqS5xSUr6 8AWdEGdoo4di6P3R8cVD4pyuzXh6bubdvVNzib5vwBItCJn7dieUlHCPZhM5CoOpuVtk jLEA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fZ1gJzs1; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-209563-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209563-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6ef5d15775si396742566b.834.2024.06.11.02.33.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 02:33:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-209563-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fZ1gJzs1; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-209563-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209563-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B65EC1F2A317 for ; Tue, 11 Jun 2024 09:24:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 98CA3176ACD; Tue, 11 Jun 2024 09:22:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fZ1gJzs1" Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D0C2176AA5; Tue, 11 Jun 2024 09:22:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718097778; cv=none; b=YXbhhf6z0KXj2hHaxHmmthaYB2hgVLxIoSITltIOdXn3tSyBv0gOjx1SL1e1G6IHCO3hsadIfIhNSinpUeWIAPJKri+H4tBVPJ9V1V/EUf3BWouM8TjIjPHl/+pd3uVIoS3o2NIa7y9JJX0UQzjCEufPKO2slaZNhwcn2k2glqw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718097778; c=relaxed/simple; bh=fp+JF0PenIVfExF3Ol/7GygM77eu/W8K9n56K0f0dDE=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=K0AqWD6lGe5OqJYvgTOP6s04MD1yR5T5j1hmU56Ede5tgdnaGrQsVtYAh8MlhnOM+4J+rjAMzRE4kygVJTkVmdBAvYHzR8c0QkZut4dYHcBILXPzCgor41Scp5XYNwtHGJWCA/MMc/mzUtvxIkbrnxEYgmdz1C1kpbsTaOMUGDQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fZ1gJzs1; arc=none smtp.client-ip=209.85.167.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oi1-f178.google.com with SMTP id 5614622812f47-3d215a594b9so1970597b6e.3; 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=vger.kernel.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=fZ1gJzs1PrqWMcgqeC1Y72yfwRVHJE0nlU1CEHuGuBBdZd0lpCg/TVMHLS0DTCIGmk MOlgWeslS1XBNW9bGfOK51PjgSAf+nkvyfz69Cqf6503oV76KMJI7k33/gA26/1NUog6 XrYqfeDRfmPY8BirSrse6sfbwdadViCsyDZZ6Cq9L9x+lXhMmqsMz7rOPXPoECmRic3u scH7WCQW7uZXxGjhwSQ5hOn4GyriCbRQZvM2KZnL4Dc9NUDUntTdNCsNcHWk4cTjxFeT UGknZ6zEsABSi8u5cm6ETEhRQ5Lr8bRjDgJohBR/42sw0Xa6RnDSc6N8pytaWTgn79Nw AYAA== 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=FIMt72QHc0KaXDYxzYmpUjDJ3syRA18IHI9CBbealqQ6vRPTyciWrilSxBLjKTM+i6 hqAfjJxgxvUwWOGJyZG73exWMipSpH76TNK6HSIvrm2CrkyWJIxpYKZz46NzxkPARMo/ tzNM9+TR518XUMOm2uU4VAJtZvfoYDrrM3vkBjQqJ8vL3JGRGP3/TR7b1bkireBskxdc asIPxTM1e12TyLJ4Eex5mk33Lvk4VtLbohvqNV/3p5rWSQDkQ1h1okWEpFtqBnfmwNW/ Y4kZu3cF1VdU1sbD9nGQn7u3mqz+v+PU3Ps0w07IaUxr8t+TsKqEXFIF2dsUj7Vteq/S sEcw== X-Forwarded-Encrypted: i=1; AJvYcCViaVQIFfkuudm9ipcl0Hc9u2vUsY2FeWmVgfZGHavz/lNxDQxoSkRJUd7LNbxRuFrrPTyHaWuriuMUAY7lYXRMVNTr91mE1IU9C+7CPFHoHjbM3vNpvTIl45G3MGV/jtz237XlsFmm2Wb9 X-Gm-Message-State: AOJu0YyZU9dpwlbs/bsYEaWTKtX7aUSdLbHyoIB5mjYSY0OaLlQUV2AM XBDP3yrn4CkX5JLiVfe/EhoY0d9PQLlaCrx7a3yfrYcgUZ/aRDuD 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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; -- 2.34.1