From patchwork Fri Jun 14 05:45:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacky Huang X-Patchwork-Id: 13697884 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 D97EBC27C77 for ; Fri, 14 Jun 2024 05:46:18 +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=iFWPlulDgeo8nuyNyqmM5xu7CgTaxuH0bDTkaYa0rIc=; b=d8FcoY1vDrnsybS5BYxrSZ1aIK ZAv3lhv9OVZzv4wklWluO8wEkQZ7wpPPCZGJFkaCPT9shKLYiWaSpJRRbE9JFXm7vkMS4chs8GIzA 44WyZmdd5qpbnxY0T2pwp4qsR9SyM8Nch+c1l+iG38MIGF4Hzr95/L8LLNFUZFMC4eRSakpUX/O9k xLN/abXioiyC/ejeh8+GIopHwbWhNzZkYdD959wrpzNQcVNgt7I89lwOXCGdd2jYcBxEG7oXwXOmA YbqQ4YzyUvov+D+tyBrbkjcELELH8nR7QJ8lxIhzVla7VS34eOwlukEMqqZrgr+lkHDWowQAjkli1 FgNJGyQA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sHzlF-00000001XUD-0nld; Fri, 14 Jun 2024 05:46:05 +0000 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sHzlB-00000001XTZ-2eyV for linux-arm-kernel@lists.infradead.org; Fri, 14 Jun 2024 05:46:03 +0000 Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-2c19bba897bso1605084a91.2 for ; Thu, 13 Jun 2024 22:45:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718343959; x=1718948759; 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=iFWPlulDgeo8nuyNyqmM5xu7CgTaxuH0bDTkaYa0rIc=; b=U5cz6NCRLk49cLuUsDtlmmDd6NnhT68gswrPuCm1f3E3n6R2nIu9iGws3TujG6sJSr dDYeEld52AnRgGojGZj/UjFm3ty8/+pPJsvZ65EOiBjoNVWbW5Iez/qBzSPhPGnYSKU8 2oacemjctUAHNIOjtVjbyXVvO3cbrbi6oA0t7hdZh4SpebvCiMI9T/D19af5i5xZiXr/ jb5OhDOK9Cnltzu4h0U46KPcyWlS1I0qhsKtmGDqxSV9oK7Gwuw6VJYwKfniywUAH4hb 6jl4JN5pdR7ubszDl5N8IrtckPSaYnS+zrYNsqnjnXox+qpqrCpW247Ix1TfoQlJjduT xmHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718343959; x=1718948759; 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=iFWPlulDgeo8nuyNyqmM5xu7CgTaxuH0bDTkaYa0rIc=; b=NT7ARrh7h1qj/XJcOzV672vgrD4UUYQ08rplJ5OI8lIA1/BM8B5NaTz1jH4O7F6P79 u70gvGOnjtr7HYliYXMH6hoz72Ef1o9b6JM9RFfPc3DHqL7KbgcHKxWXLbNI8SXjeGEJ 7l836cukYVqDLfR0Y1r0RmEpUp+hND86fZ0xok6PGfBRyWq9zdI9Yle0sK/KELfuCfsH Pz3hxH5q7CXrvpig76qdeRCFjs4FoOId8Nxsw4U4DI5mTf2W/IhtRRmrJjxB7fheWnJ8 /WkL96Rl+FvZJy/GlLjb2jLAJogMrCoZc0167ySPLsp3Gc0zFyPU8IweJ+kUaM4ZMiTT 5h4g== X-Gm-Message-State: AOJu0YxoNEEXsszFdcTwwqw3+59JiFZqIrVXq+jRKHsEpAtCXZMO9zwl vX3wyhEdfn2CrP69MvRKYW8zdTjV3+/1AZX1KMFWSVTWfeSPbnjab2ogyA== X-Google-Smtp-Source: AGHT+IFN83p9O9atJzcMT+s+gHJY2ZZ2Q2NH1n5vXQA4BDtC2yeINZ7PMPFxt2qa8rJKgBFabUYAnw== X-Received: by 2002:a17:90a:af04:b0:2c3:4ea:94bc with SMTP id 98e67ed59e1d1-2c4dbd440a1mr1581525a91.47.1718343958670; Thu, 13 Jun 2024 22:45:58 -0700 (PDT) Received: from a28aa0606c51.. (60-250-192-107.hinet-ip.hinet.net. [60.250.192.107]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c4a769c8aesm5115536a91.39.2024.06.13.22.45.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 22:45:58 -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 v2] tty: serial: ma35d1: Add a NULL check for of_node Date: Fri, 14 Jun 2024 05:45:54 +0000 Message-Id: <20240614054554.80-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-20240613_224601_773647_1BFC2C12 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. Fixes: 930cbf92db01 ("tty: serial: Add Nuvoton ma35d1 serial driver support") 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;