From 55ca589ab9e6e719c1e1f9fc72997d1643d28fe3 Mon Sep 17 00:00:00 2001
From: Allan Xavier <mr.a.xavier@googlemail.com>
Date: Thu, 12 Jan 2023 12:08:55 +0000
Subject: [PATCH] Fix rpi-eeprom-update when using busybox find

The busybox implementation of find does not detect recursive nested
symlinks, this results in it finding multiple instances of of_node
matching -samefile, the result of which then fails the -e path test.

The of_node symlink we're tyring to find should match the path
/sys/bus/nvmem/devices/*/of_node so just limit the find depth to 3 as
there's no point searching deeper than that.

Signed-off-by: Allan Xavier <mr.a.xavier@googlemail.com>

Upstream-Status: Backport [https://github.com/raspberrypi/rpi-eeprom/commit/55ca589ab9e6e719c1e1f9fc72997d1643d28fe3]
---
 rpi-eeprom-update | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rpi-eeprom-update b/rpi-eeprom-update
index 79eb3bf..cb25316 100755
--- a/rpi-eeprom-update
+++ b/rpi-eeprom-update
@@ -126,7 +126,7 @@ getBootloaderConfig() {
 
    if [ -f "${blconfig_alias}" ]; then
       local blconfig_ofnode_path="/sys/firmware/devicetree/base"$(strings "${blconfig_alias}")""
-      local blconfig_ofnode_link=$(find -L /sys/bus/nvmem -samefile "${blconfig_ofnode_path}" 2>/dev/null)
+      local blconfig_ofnode_link=$(find -L /sys/bus/nvmem -maxdepth 3 -samefile "${blconfig_ofnode_path}" 2>/dev/null)
 
       if [ -e "${blconfig_ofnode_link}" ]; then
          blconfig_nvmem_path=$(dirname "${blconfig_ofnode_link}")
-- 
2.34.1

