Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp206705lqs; Thu, 13 Jun 2024 08:02:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWiQjvTw4dWiDUlJvHKb+4ZWHN7hVxkpFmlyj88mSyclhNsbxPGCLAXNHB16w41fEZwIozRu8sb5qJ4X45OPep8GUfzfD7SOj+FdaemAw== X-Google-Smtp-Source: AGHT+IHXt/aFQwJjupEXBA3qi3mCN+L42iVwyL+XQ/z/To1tNazT9C0utytOqe9RQlVqvRLh2guo X-Received: by 2002:a0d:c947:0:b0:627:cfe1:1c21 with SMTP id 00721157ae682-62fba9433ffmr46312117b3.47.1718290935102; Thu, 13 Jun 2024 08:02:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718290935; cv=pass; d=google.com; s=arc-20160816; b=c32jE6bfY9THpv3wdW74sRk7uehKoWCehh4kG5C4IfqYdGBBscUW9G5Tn6GA3jlXwi M+1bZxNR/4Cp8AJJAMbkLR+7OB2zMhdlpo+1fYNzoAqBb8WzmB9FIaI1k9+TqGE4I6WU ovSu2wogdE/BGnwuS8/u38LsUNHpv9NzfJ34KkO6ybkf9RzhkhbWjqEqUIgVUISWZDOt RgMtKX7YObRtE240peaDr2ijV9oN5BSvvoTUEPFjqbTe50QvHt0RBb3SukJrA5kLTiZb he7WK+NdkRSXj09ieGSrA0NpPcXyDAwLmg3HshwdedXGBowGGdpXX05emtCmSBoO2ZRg ODMA== 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=U8DQ5VScKhFQSJasWhNy88C3p44N18/s2PVWHrzDJ1M=; fh=n10TG+Zf2XN9jzqwdWEIn/XgTDOMfhAE4wD6DqWX92A=; b=WL5H98XD6KTRRagmUJWCGieWcBTjX+iZxU6+o2zKLi3jnFhisJFhfZJ9xNo4aV9Awo OYGuPTl4qHrUBteO96bIJGz6q8ETdBq9EJovSoFatRVWfDOfHp0wHI+qgg0GareYG3wf bF/OaUaIIfbaHmV9oakP9nTaYTl2heDC1AGOdXP8wZ0tRSBTwMik6PsQiToG+X5Y22nD q/IFQ/D405522trHUy1T8ZE1IuqugbAYl809/tHo3dQbk24eI0xUaQYbvJxPgC4UcRG6 OnAhRTvnKbzypuEWfDdfwZnVVJVAgCT48KQw7tmm6vOjQDl1PRi690OSWKXHrDqtbsPS WPEQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fxySFIUL; 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-213483-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213483-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 00721157ae682-6311aa23ae6si4584017b3.232.2024.06.13.08.02.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 08:02:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-213483-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fxySFIUL; 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-213483-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213483-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 9EDC31C23338 for ; Thu, 13 Jun 2024 15:02:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D13DE1494A0; Thu, 13 Jun 2024 15:02:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fxySFIUL" Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) (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 C1DFE84A41; Thu, 13 Jun 2024 15:02:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.68 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718290930; cv=none; b=QtaCQUMuMsF6gb4gdKNg1Z4JYl3qTAiK+HSFV22SJjZ94XnIUf2oi4Cy/OeGY1oYq4rb0TOxdL0xVqhbLb7J6XEIGxFglxER4KCXewH57Toh9gUUcYbkAHHf/h4v8GOEMqlFZQ7KYkjX17x5sRsX34XZT6G4+YVZjm7iLR816X8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718290930; c=relaxed/simple; bh=0vwy+oNU5J1EjAO5qZ9rH2UnBq8fpSIO7ukwd4fnDiY=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=ANnE6Eyfchk1v/RJNB+tVatFjtDZ7M5a0/u2fQrxOJ9mATIwtZAzzutnrODb2UW0nXVS3xQxh7B50TTxZkXk+9IuhZXo+iRVyDhybY4JVmBdsxlNf068GbQaF0X1qFbVx5pkHjoO2Zbkizu3kKZje1b81VmL/rFiOVcE3PoTxzQ= 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=fxySFIUL; arc=none smtp.client-ip=209.85.216.68 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-f68.google.com with SMTP id 98e67ed59e1d1-2c2c6b27428so883025a91.3; Thu, 13 Jun 2024 08:02:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718290928; x=1718895728; 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=U8DQ5VScKhFQSJasWhNy88C3p44N18/s2PVWHrzDJ1M=; b=fxySFIULOcSiU0j8shdFXj0olcsY+r+SysYmEGW/WSrpyngMxwkClo2R3hDh/66jv7 Vz6atNia+R0FBl1KpQdniQjZ0Q6T9kzY/W1nCpGJr3+hf75tKezHT0gOsw6a42SqRv17 +IbTq0/56LEjj9oAsQVv9snCrcBiT6G2eXPy7uXts9ztF1XV6sKEEY9uJWtYaHsRyYdV ng7MYh0ZfsQ+nVnxtDrMLRYSMLpAVkR0K+cNlGdudrZQuP73jD53RhSlOLHh451RDj27 RhdAdLi/FJW2MO1YraGJgfNqlrf/dOViVtxFXiJhcKmIEGzXHNTzGBJ0yEOWEjqqfXgQ Z98w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718290928; x=1718895728; 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=U8DQ5VScKhFQSJasWhNy88C3p44N18/s2PVWHrzDJ1M=; b=psUZgNkoirgXmEE+P5G+nRhWFBupfeAFNRYLgjURP3SCN2S3SKFyClMR/UOiXvlwRg CUrtASxMioLTleGNCc7vcawbQhOlK+fi7IOPvcN9V/v+u5KhGffJ+diDuhIVk3t3F8ts T1clQCwbBWZJDniHbXGQToNkV44jBf4xz2KN72F4fu00jS83ZiNYfONm4McXeBvdaRXy p7w2/PR2TdIOp400HlnbadFOnI8l+ATuuWV8KHSpj+jJeWDYxWjh31gU3mus3QlcSXLC sDwbc2AJ/tYrDglPrYUJPmOPfvDxEKQdB+B6NK8puI3DoLlBM72MmoBTEh6VuDPKqDr1 RdQA== X-Forwarded-Encrypted: i=1; AJvYcCWhwpK1889lJfTwBqv3a0NIEtX7b2NkiWzqGSUM3tBGjS8cTdCgnjZlSfS0AeEFfz/IDXBRk0Ot+9jrQ8lTrLY+/1BjCcON/tykqXX8 X-Gm-Message-State: AOJu0YzBcvsjGYY7tIj2zYlUZQ6mV4l2LLJZvBv4PNpb25L58zYQ5jxo tAbSKfdSM1SfQ1feFLuND/6I92seEk5PmN5bh2ALM2KAIHvYjoSC X-Received: by 2002:a17:90b:3c1:b0:2c4:b2d3:6c8d with SMTP id 98e67ed59e1d1-2c4db129158mr13502a91.10.1718290927718; Thu, 13 Jun 2024 08:02:07 -0700 (PDT) Received: from localhost.localdomain ([121.139.28.121]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c4c45ad12bsm1841234a91.7.2024.06.13.08.02.05 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 13 Jun 2024 08:02:07 -0700 (PDT) From: Gyeonggeon Choi To: robh@kernel.org, saravanak@google.com Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Gyeonggeon Choi Subject: [PATCH] drivers:of: Add null check for bus in of_match_bus Date: Fri, 14 Jun 2024 00:01:34 +0900 Message-Id: <20240613150134.66329-1-gychoi.dev@gmail.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Added a null check for the bus variable after calling of_match_bus. This prevents potential null pointer dereference errors in subsequent code, where bus->count_cells could cause a crash if bus is NULL. Signed-off-by: Gyeonggeon Choi --- drivers/of/address.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/of/address.c b/drivers/of/address.c index d669ce25b5f9..85f986d25870 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -504,6 +504,8 @@ static u64 __of_translate_address(struct device_node *node, if (parent == NULL) return OF_BAD_ADDR; bus = of_match_bus(parent); + if (bus == NULL) + return OF_BAD_ADDR; /* Count address cells & copy address locally */ bus->count_cells(dev, &na, &ns); -- 2.39.3 (Apple Git-146)