Skip to content

Commit 8995d64

Browse files
Grippy98igorpecovnik
authored andcommitted
Validate PB2 USB device controller before binding
1 parent fc3ccd2 commit 8995d64

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

packages/bsp/pocketbeagle2-usb-gadget/pb2-usb-gadget-ncm-acm

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,14 @@ if [ -d /sys/module/g_cdc ] || [ -d /sys/module/g_ether ] || [ -d /sys/module/g_
103103
fi
104104

105105
cleanup_configfs
106-
UDC=$(first_udc)
106+
if ! UDC=$(first_udc); then
107+
echo "no USB device controller found under /sys/class/udc" >&2
108+
exit 1
109+
fi
110+
if [ -z "$UDC" ]; then
111+
echo "USB device controller name is empty" >&2
112+
exit 1
113+
fi
107114
USB_SERIAL=$(usb_serial)
108115
DEV_MAC=$(derive_mac 02 pb2-dev)
109116
HOST_MAC=$(derive_mac 06 pb2-host)

0 commit comments

Comments
 (0)