From patchwork Tue Jun 25 03:29:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacky Huang X-Patchwork-Id: 13710574 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 37E35C2BBCA for ; Tue, 25 Jun 2024 03:29:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=cbyQAZieaq4eQ23w2TzylROJa2sRShj9GyMl0x0ukyk=; b=H2i1zmB0KyJxeBoN6IOEfCPAJQ laMbDBTj4axx88UtfMNZTkl5ktLX1WRelUivIgwEzwc/wQEtY5QeURaCMveMQ4UqzJbX9S2AxEqt8 7XlRAlQ52UqRLyVaapo8tVc6cxyMlQpwAN5JuFqlwEa+3pDGqn79Ztczx1D4PNAT8NQnxKX90c4IZ W33ewvpwlJxb5xG0DQls06MdV5SWyRJYC58vwvnFLpw2x7upaWydKBrnP+O2p/6hMEqt9Zfd2Res+ MCElNJVOBgwXogFNdzaEBMjDnqg85f5i9o5w8SAkh9kdRnN00tMdnQbA8Bnf0c7v3a4ROpxkNomIh C6CcrBcA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLws8-00000001Sia-1AZ4; Tue, 25 Jun 2024 03:29:32 +0000 Received: from mail-oo1-xc32.google.com ([2607:f8b0:4864:20::c32]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLws1-00000001ShJ-2cXz for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 03:29:27 +0000 Received: by mail-oo1-xc32.google.com with SMTP id 006d021491bc7-5b97a9a9b4bso2413946eaf.0 for ; Mon, 24 Jun 2024 20:29:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719286164; x=1719890964; 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=cbyQAZieaq4eQ23w2TzylROJa2sRShj9GyMl0x0ukyk=; b=IcQbolybMsHwjefhQmPH//3W10UMscC79lqwlGWSSgir0OKta3djZUVJLQV1SKcWLV Zxiylm9ETBdl6cd3UUjmVGRkd1VABhTg/iHR/ac1YV4P3njyF3elUJV86lcvabZVeRhO WglZrHBVxxNzrTcu/ODy+wsOxn8p4LoHofijx8i6Wmhq85s9BBPSNamqdFClTwQA3Bid SrhdbOCZtBU9saAoGYEvsc/0WH8m4sqm2WMd/VteNW84JrJ0ZeavdPL8nYuYXRfM4/SP k+AanspvGPG0cRRWZjxc3X9OsHSxZEe59jn6Tsy9IabOkwG9iQC4WwaxnWuYtvogPqrR 1fTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719286164; x=1719890964; 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=cbyQAZieaq4eQ23w2TzylROJa2sRShj9GyMl0x0ukyk=; b=dop2/5tQsrvxqZKTLNuWx4JdYkqU8n/6YN7kaGg6b3obZnFDgag9rFPRDuVqRfHr4l 2VcpXO1eIvRu/8BUmR8cC0zQFmDDhg+WzqJTkTiYBTiTA/7XStyCE3golfhggxweHgbN I/V+AWko/8+IAgzNae4r/8SpxzgO5GqS22FKtXdMm8dSU5/G6Oo+5zWt6KpSACxN5Whc xheQT2l6TqHwxbguw4TaaqZJbgn2PuK3sUejHyhBFdr/+aT12enmm1KOYQg3zz1FLvS7 4bBy5CjC6IgOefbBz7KZgIDdryfA49H/Svy5ra1sugVRHTBny5iCDDfjd9DRjbSN0PUq Ajtw== X-Gm-Message-State: AOJu0YxErxF3l8UVY8RcD5HZBiZgkaA5lCNV4lnX+5rvFf3c4jlw+nPa ggUZgQ+KkL31vpDTZLXmq7m3EyPuJ0tfFvzDHEicZn5SjTBgjJ4BB8yB3g== X-Google-Smtp-Source: AGHT+IFGBxRpq0C82hTfGZ42YkgflUopHUOHx0vsbP08KBRE2jMXSSB/smCiH3gnRYrK1egFXazYJg== X-Received: by 2002:a05:6870:55d0:b0:259:89a5:440e with SMTP id 586e51a60fabf-25d016d2a18mr7438054fac.27.1719286164365; Mon, 24 Jun 2024 20:29:24 -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-7067ce3670asm3288937b3a.76.2024.06.24.20.29.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 20:29:23 -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 v3] tty: serial: ma35d1: Add a NULL check for of_node Date: Tue, 25 Jun 2024 03:29:19 +0000 Message-Id: <20240625032919.73-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-20240624_202925_693653_D911CA62 X-CRM114-Status: GOOD ( 14.34 ) 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. v3: - Added "Reported-by:" line. v2: - Added "Fixes" line. Fixes: 930cbf92db01 ("tty: serial: Add Nuvoton ma35d1 serial driver support") Reported-by: Dan Carpenter Closes: https://lore.kernel.org/all/8df7ce45-fd58-4235-88f7-43fe7cd67e8f@moroto.mountain/ 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;