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

Avoid crash on NULL pointer in lock driver impls during hotplug

When virLockDriverAcquire is invoked during hotplug the state
parameter will be left as NULL.

* src/locking/lock_driver_nop.c,
  src/locking/lock_driver_sanlock.c: Don't reference NULL state
  parameter
上级 09240ef1
......@@ -76,6 +76,7 @@ static int virLockManagerNopRelease(virLockManagerPtr lock ATTRIBUTE_UNUSED,
char **state,
unsigned int flags ATTRIBUTE_UNUSED)
{
if (state)
*state = NULL;
return 0;
......@@ -85,7 +86,7 @@ static int virLockManagerNopInquire(virLockManagerPtr lock ATTRIBUTE_UNUSED,
char **state,
unsigned int flags ATTRIBUTE_UNUSED)
{
if (state)
*state = NULL;
return 0;
......
......@@ -374,6 +374,7 @@ static int virLockManagerSanlockRelease(virLockManagerPtr lock,
virCheckFlags(0, -1);
if (state) {
if ((rv = sanlock_inquire(-1, priv->vm_pid, 0, &res_count, state)) < 0) {
if (rv <= -200)
virLockError(VIR_ERR_INTERNAL_ERROR,
......@@ -386,6 +387,7 @@ static int virLockManagerSanlockRelease(virLockManagerPtr lock,
if (STREQ(*state, ""))
VIR_FREE(*state);
}
if ((rv = sanlock_release(-1, priv->vm_pid, SANLK_REL_ALL, 0, NULL)) < 0) {
if (rv <= -200)
......@@ -409,6 +411,11 @@ static int virLockManagerSanlockInquire(virLockManagerPtr lock,
virCheckFlags(0, -1);
if (!state) {
virLockError(VIR_ERR_INVALID_ARG, "state");
return -1;
}
VIR_DEBUG("pid=%d", priv->vm_pid);
if ((rv = sanlock_inquire(-1, priv->vm_pid, 0, &res_count, state)) < 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册