usb-devices: use 'local' variable type to handle recursion

When recursing into a long USB tree, the local variables in the
print_device() function would get confused and take on the value of the
previous device it printed.  This caused devices to not get printed out
at all, the exact opposite of what we wanted.

Resolve this by using the non-POSIX 'local' variable declaration.

Signed-off-by: Greg Kroah-Hartman <>
diff --git a/usb-devices b/usb-devices
index 4e14608..9aca88d 100755
--- a/usb-devices
+++ b/usb-devices
@@ -101,10 +101,10 @@
 print_device() {
-	devpath=$1
-	parent=$2
-	level=$3
-	count=$4
+	local devpath=$1
+	local parent=$2
+	local level=$3
+	local count=$4
 	[ -d $devpath ] || return
 	cd $devpath