Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp598817lqs; Thu, 13 Jun 2024 22:46:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWtXpjSYt7lXRWntFVzeejgCw5bESY0hhXu1p9dP+yZj65wzEIqT5slnR9vKcwsFoOxCQLMbkandhi0WX+Kh1ONJNMZP+2D3cWilMVBSw== X-Google-Smtp-Source: AGHT+IG+xBrwKEYV84BnMRiE6102haCcrMemiXlrBWtiW3n9UzNtWDTgJD/sDSpW3naA0IlbXv1G X-Received: by 2002:a17:902:ec8a:b0:1f6:fcd9:5b86 with SMTP id d9443c01a7336-1f8625c35a8mr22444355ad.12.1718343966914; Thu, 13 Jun 2024 22:46:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718343966; cv=pass; d=google.com; s=arc-20160816; b=0I22VAIvygI2FBJI5WbyeeAyph8vs8l6Hno6c2Bk+etgnyKButvfx5C1Ug0Y6XP4Kz x3u222zB8OPtpmpTlANt1AS5fdRED6eNej+Tm2nA8BhIdEyhWnc9jpOoHAesiFZymb3f hXiX6WvmSL8Xnsmofh+yjh5DbpGVSf6vYtWnhkZgAczGG+CYZQFWo74l2hwbilX06b7e 3FhLEUMC9A1VT4zkXgDPAyD9twwcLdR4QU4N7sxJ4gq+8X3tUvnTw6186TMCU7UUehP3 njXeAIZHHp2XB0HBd4sC074o3xNJ/ztIZsSojA9Ob7MTZ96RRyfyyU7Dds3yxgeiVwly H5WQ== 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=iFWPlulDgeo8nuyNyqmM5xu7CgTaxuH0bDTkaYa0rIc=; fh=CHxLOjy26p4UMJQhg4D5haHi1Mor3cMH4PQ29TTLPk0=; b=g6SKYZGVXjftIu2myqLEANW7uogWiBr2Xsi8bXNHhMXM6p8aYoRyiAzMyYlne9a51j arS6uNjsXA34pe0yMVtv+x2qKvP1GTKib85CVIVxseje7fE0oIHkIq9YRvDPJkUk+qmH /62i+oiYcVfD6V0NDgS6CW9FIIWAN7mtd3RKDLlBsavrASAP7CCDJoNyv5NqY7sBN/Cv DNHck4+WrxXR89VkmOOd8um4lPsiRJiVp1VtZJ1FyQZutxUoH3Qf6KNRVjYIIx3setMN NgyT+lyzyF5gA99KSxduO0fVjttknz4x+ciTD3F7AUwMoPvDXPgqhjD39uY4cu8ilHXp TsJA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Pek3zBe9; 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-214374-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214374-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f855e3adbbsi28110005ad.14.2024.06.13.22.46.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 22:46:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-214374-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Pek3zBe9; 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-214374-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214374-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B5A9728413A for ; Fri, 14 Jun 2024 05:46:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B72841474BE; Fri, 14 Jun 2024 05:46:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Pek3zBe9" Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) (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 9BF12146D76; Fri, 14 Jun 2024 05:45:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718343960; cv=none; b=DaIE6CYg39lOS+YbsAI9Cl5YVtJjzcG4O5nfgSxpMtaukc6U1PIgBx2BF+1qK1hM77SOZCk0nd7mRmJSgi/ySqFbvGZ8Vu21bgfe0pfChJnwPUnxbbgfP6kiYgsU0iIY72zsIhJipJm3jVKv8xhkmXduWPiX11GOR71bvNrcybU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718343960; c=relaxed/simple; bh=cwZyF+XEGrqGRrFP15+iF9G07AtfyPuX0yJNnxRLfrU=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=m7+eXsF5pq9hnrsHR+9UL8HboFt5aH+mnZeCt3h9byOm685c+ijlst79JJ2MS1UgJFOxeYXxY5FBjzTp+M6jeGGp8imqKXTdpkTtapnYukKfRy9Urx9V7sV5+tVW9ndfs+qB1mAHx0lpLlV4L13kd7kyyI69tNb24xL05aPnQqM= 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=Pek3zBe9; arc=none smtp.client-ip=209.85.216.46 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-pj1-f46.google.com with SMTP id 98e67ed59e1d1-2c2dee9d9cfso1603478a91.3; 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=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=iFWPlulDgeo8nuyNyqmM5xu7CgTaxuH0bDTkaYa0rIc=; b=Pek3zBe956DKVArJdOPXQLT3WpldMHRmY2tx4QLUzNYPAr2cTCA1+sP6rnC+/4Nhmv YhmVqVPjnzywsRICbXQvQkdMLLvbOryz/hle3Srw1wzCksLUuEOKWMJxjAm78ombAWxE QK+NVqAQmrsWvvmDGblVT36Zn99jmZPwqnTNyC26bay7sf6ZG0Rs53KPOELUgAg+/waG n/QUVweLOsCP3jKfyvCUTkgc0d2Uf7tyzSfyZf/pleGcGA8jCjDkPV8us4fxqlykwbOa eonrtwFoCzjtzqC+3OD2RzRVZ8vMn8dVnBU4W+2LdNL6SBFuB9wP1wnVWWy5IR3njwpF teJw== 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=Fb18W26lAUP8+PMl8VKTTbBIPsAFBgeIDPsslHuSArGhpjvZ7IQxW87kDYR1bxTjXM rlor0c93Jx1t4JtIJDmDwToxj97Glo60OzoJYYmXFGCUREJxLzfUd/izjeUjfV6c09RZ +K7oi/5LOGtQuA+glGgrxINaCn1jdmyALWslxulBL/4YrZr6xTd0qsLLUuK2V6goDP97 IYgvfCNfVz9GuMkzwsZwuvvRhQKvr3a24CgAIn0UJciIiYO3oqeXE3IGd+vc120NATMI sWnIY7lQVoXT+MSf4m7TzX4co/CsQ3cDbptEFdvYnJ8gyeJFjmsc6WD4dDESzOPxQmg8 JWTQ== X-Forwarded-Encrypted: i=1; AJvYcCWxpwsvC0tlQwtSo+RGdE9MI3KA09uyFLzmGdAcd7pBk6WjXny1C2v0BmRR7rXChiyDApixcpbBeV37el6iJH+fxQr6EjyZ9QlID0DimdHADaR/aCuncWjljK3eBCscoziLi75G9XzJEf7M X-Gm-Message-State: AOJu0YwU60khRZyqMzuDlzBZed1A3NQRtwoH66W2O9ckc5L8i38TJBlg L/aptLiI1rY8bvMpAE8xLD4b9LuJ02si1FbY2bk23zAiei0vOCOK 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 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. 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; -- 2.34.1