From 1c9e46d6e5008967dcbbd3fa00ed0f20fee3fdd7 Mon Sep 17 00:00:00 2001 From: Jongmin Choi Date: Wed, 28 Sep 2016 19:55:29 +0900 Subject: [PATCH] Fix the bug in RemoveDeviceInfoFromLocal API Fix the bug in RemoveDeviceInfoFromLocal API in case of remove the single linked device http://suprem.sec.samsung.net/gerrit/#/c/93085/ Change-Id: I88f025cb589a7893323197aa321d312d62f9be52 Signed-off-by: Jongmin Choi Reviewed-on: https://gerrit.iotivity.org/gerrit/12405 Reviewed-by: Chul Lee Tested-by: jenkins-iotivity Reviewed-by: Randeep Singh --- .../provisioning/src/ocprovisioningmanager.c | 24 ++++++++++------------ 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/resource/csdk/security/provisioning/src/ocprovisioningmanager.c b/resource/csdk/security/provisioning/src/ocprovisioningmanager.c index fdf9010..0d488f4 100644 --- a/resource/csdk/security/provisioning/src/ocprovisioningmanager.c +++ b/resource/csdk/security/provisioning/src/ocprovisioningmanager.c @@ -332,20 +332,18 @@ static OCStackResult RemoveDeviceInfoFromLocal(const OCProvisionDev_t* pTargetDe // Remove credential of revoked device from SVR database OCStackResult res = OC_STACK_ERROR; const OicSecCred_t *cred = NULL; - cred = GetCredResourceData(&pTargetDev->doxm->deviceID); - if (cred == NULL) - { - OIC_LOG(ERROR, TAG, "RemoveDeviceInfoFromLocal : Failed to get credential of remove device."); - goto error; - } - res = RemoveCredential(&cred->subject); - if (res != OC_STACK_RESOURCE_DELETED) + OIC_LOG(DEBUG, TAG, "IN RemoveDeviceInfoFromLocal"); + cred = GetCredResourceData(&pTargetDev->doxm->deviceID); + if (NULL != cred) { - OIC_LOG(ERROR, TAG, "RemoveDeviceInfoFromLocal : Failed to remove credential."); - goto error; + res = RemoveCredential(&cred->subject); + if (res != OC_STACK_RESOURCE_DELETED) + { + OIC_LOG(ERROR, TAG, "RemoveDeviceInfoFromLocal : Failed to remove credential."); + goto error; + } } - /** * Change the device status as stale status. * If all request are successed, this device information will be deleted. @@ -353,8 +351,7 @@ static OCStackResult RemoveDeviceInfoFromLocal(const OCProvisionDev_t* pTargetDe res = PDMSetDeviceStale(&pTargetDev->doxm->deviceID); if (res != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "OCRemoveDevice : Failed to set device status as stale"); - goto error; + OIC_LOG(WARNING, TAG, "OCRemoveDevice : Failed to set device status as stale"); } // TODO: We need to add new mechanism to clean up the stale state of the device. @@ -368,6 +365,7 @@ static OCStackResult RemoveDeviceInfoFromLocal(const OCProvisionDev_t* pTargetDe OIC_LOG_V(WARNING, TAG, "OCRemoveDevice : Failed to close DTLS session : %d", caResult); } + OIC_LOG(DEBUG, TAG, "OUT RemoveDeviceInfoFromLocal"); error: return res; } -- 2.7.4