提交 7617e5e4 编写于 作者: D Daniel P. Berrange

Avoid crash on OOM in virlockspacetest

The virlockspacetest.c did not check for failure to create
a lockspace, causing a crash on OOM
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 0b30d345
...@@ -44,7 +44,8 @@ static int testLockSpaceCreate(const void *args ATTRIBUTE_UNUSED) ...@@ -44,7 +44,8 @@ static int testLockSpaceCreate(const void *args ATTRIBUTE_UNUSED)
rmdir(LOCKSPACE_DIR); rmdir(LOCKSPACE_DIR);
lockspace = virLockSpaceNew(LOCKSPACE_DIR); if (!(lockspace = virLockSpaceNew(LOCKSPACE_DIR)))
goto cleanup;
if (!virFileIsDir(LOCKSPACE_DIR)) if (!virFileIsDir(LOCKSPACE_DIR))
goto cleanup; goto cleanup;
...@@ -65,7 +66,8 @@ static int testLockSpaceResourceLifecycle(const void *args ATTRIBUTE_UNUSED) ...@@ -65,7 +66,8 @@ static int testLockSpaceResourceLifecycle(const void *args ATTRIBUTE_UNUSED)
rmdir(LOCKSPACE_DIR); rmdir(LOCKSPACE_DIR);
lockspace = virLockSpaceNew(LOCKSPACE_DIR); if (!(lockspace = virLockSpaceNew(LOCKSPACE_DIR)))
goto cleanup;
if (!virFileIsDir(LOCKSPACE_DIR)) if (!virFileIsDir(LOCKSPACE_DIR))
goto cleanup; goto cleanup;
...@@ -98,7 +100,8 @@ static int testLockSpaceResourceLockExcl(const void *args ATTRIBUTE_UNUSED) ...@@ -98,7 +100,8 @@ static int testLockSpaceResourceLockExcl(const void *args ATTRIBUTE_UNUSED)
rmdir(LOCKSPACE_DIR); rmdir(LOCKSPACE_DIR);
lockspace = virLockSpaceNew(LOCKSPACE_DIR); if (!(lockspace = virLockSpaceNew(LOCKSPACE_DIR)))
goto cleanup;
if (!virFileIsDir(LOCKSPACE_DIR)) if (!virFileIsDir(LOCKSPACE_DIR))
goto cleanup; goto cleanup;
...@@ -143,7 +146,8 @@ static int testLockSpaceResourceLockExclAuto(const void *args ATTRIBUTE_UNUSED) ...@@ -143,7 +146,8 @@ static int testLockSpaceResourceLockExclAuto(const void *args ATTRIBUTE_UNUSED)
rmdir(LOCKSPACE_DIR); rmdir(LOCKSPACE_DIR);
lockspace = virLockSpaceNew(LOCKSPACE_DIR); if (!(lockspace = virLockSpaceNew(LOCKSPACE_DIR)))
goto cleanup;
if (!virFileIsDir(LOCKSPACE_DIR)) if (!virFileIsDir(LOCKSPACE_DIR))
goto cleanup; goto cleanup;
...@@ -180,7 +184,8 @@ static int testLockSpaceResourceLockShr(const void *args ATTRIBUTE_UNUSED) ...@@ -180,7 +184,8 @@ static int testLockSpaceResourceLockShr(const void *args ATTRIBUTE_UNUSED)
rmdir(LOCKSPACE_DIR); rmdir(LOCKSPACE_DIR);
lockspace = virLockSpaceNew(LOCKSPACE_DIR); if (!(lockspace = virLockSpaceNew(LOCKSPACE_DIR)))
goto cleanup;
if (!virFileIsDir(LOCKSPACE_DIR)) if (!virFileIsDir(LOCKSPACE_DIR))
goto cleanup; goto cleanup;
...@@ -233,7 +238,8 @@ static int testLockSpaceResourceLockShrAuto(const void *args ATTRIBUTE_UNUSED) ...@@ -233,7 +238,8 @@ static int testLockSpaceResourceLockShrAuto(const void *args ATTRIBUTE_UNUSED)
rmdir(LOCKSPACE_DIR); rmdir(LOCKSPACE_DIR);
lockspace = virLockSpaceNew(LOCKSPACE_DIR); if (!(lockspace = virLockSpaceNew(LOCKSPACE_DIR)))
goto cleanup;
if (!virFileIsDir(LOCKSPACE_DIR)) if (!virFileIsDir(LOCKSPACE_DIR))
goto cleanup; goto cleanup;
...@@ -292,7 +298,8 @@ static int testLockSpaceResourceLockPath(const void *args ATTRIBUTE_UNUSED) ...@@ -292,7 +298,8 @@ static int testLockSpaceResourceLockPath(const void *args ATTRIBUTE_UNUSED)
rmdir(LOCKSPACE_DIR); rmdir(LOCKSPACE_DIR);
lockspace = virLockSpaceNew(NULL); if (!(lockspace = virLockSpaceNew(NULL)))
goto cleanup;
if (mkdir(LOCKSPACE_DIR, 0700) < 0) if (mkdir(LOCKSPACE_DIR, 0700) < 0)
goto cleanup; goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册