From 01cbc4c6317e5be03841ec0c6610b96ff23e5b0b Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 26 Jun 2018 07:36:50 +0200 Subject: scripts/hotplug: protect against potential spaces in DEVPATH It's uncertain whether it's possible to get a device path having spaces in its name/path but given the crap some SoC vendors can do in their BSPs, better be safe. Also check that "loading" actually exists when stopping it, to avoid a useless error when trying to write -1 there. --- scripts/hotplug | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/hotplug b/scripts/hotplug index f1c6fe4..4d021de 100755 --- a/scripts/hotplug +++ b/scripts/hotplug @@ -11,14 +11,17 @@ if [ "$1" = "firmware" ]; then [ -s "/etc/firmware/$FIRMWARE" ] && file="/etc/firmware/$FIRMWARE" [ -s "/tmp/$FIRMWARE" ] && file="/tmp/$FIRMWARE" if [ -s "$file" ]; then - echo 1 >/sys/$DEVPATH/loading - cat $file >/sys/$DEVPATH/data - echo 0 >/sys/$DEVPATH/loading + echo 1 > "/sys/$DEVPATH/loading" + cat $file > "/sys/$DEVPATH/data" + echo 0 > "/sys/$DEVPATH/loading" else exit 1 fi else - echo -1 >/sys/$DEVPATH/loading + # end of firmware loading in case it was in progress + if [ -e "/sys/$DEVPATH/loading" ]; then + echo -1 >"/sys/$DEVPATH/loading" + fi fi exit 0 -- 1.7.12.1