[PATCH 2/6 v3] common/rc: _destroy_loop_device confirm arg1 is set

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



Check if the dev arg1 is set before calling losetup -d on it.

Signed-off-by: Anand Jain <anand.jain@xxxxxxxxxx>
---
 common/rc | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/common/rc b/common/rc
index 18d2ddcf8e35..e7d6801b20e8 100644
--- a/common/rc
+++ b/common/rc
@@ -4150,7 +4150,10 @@ _create_loop_device()
 _destroy_loop_device()
 {
 	local dev=$1
-	losetup -d $dev || _fail "Cannot destroy loop device $dev"
+
+	if [ ! -z $dev ]; then
+		losetup -d $dev || _fail "Cannot destroy loop device $dev"
+	fi
 }
 
 _scale_fsstress_args()
-- 
2.39.3





[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux