diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2013-05-13 10:32:16 -0400 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2013-05-20 10:44:31 -0400 |
commit | 28430573bf212b1669e0c78c682e9b298f337ada (patch) | |
tree | d067026f24e77ba96d8780a51eb31c84c3103ab7 | |
parent | 0c4d0fa8489362654226cf2d82a408685478a83f (diff) | |
download | openlmi-providers-28430573bf212b1669e0c78c682e9b298f337ada.tar.gz openlmi-providers-28430573bf212b1669e0c78c682e9b298f337ada.tar.xz openlmi-providers-28430573bf212b1669e0c78c682e9b298f337ada.zip |
Fix memory leaks
Fixes Coverity issues:
* 10153
* 10154
* 10155
-rw-r--r-- | src/fan/LMI_FanAssociatedSensorProvider.c | 9 | ||||
-rw-r--r-- | src/fan/LMI_FanProvider.c | 8 | ||||
-rw-r--r-- | src/fan/LMI_FanSensorProvider.c | 10 |
3 files changed, 24 insertions, 3 deletions
diff --git a/src/fan/LMI_FanAssociatedSensorProvider.c b/src/fan/LMI_FanAssociatedSensorProvider.c index b462e83..4253e96 100644 --- a/src/fan/LMI_FanAssociatedSensorProvider.c +++ b/src/fan/LMI_FanAssociatedSensorProvider.c @@ -56,6 +56,7 @@ static CMPIStatus LMI_FanAssociatedSensorEnumInstances( const char** properties) { const char *ns = KNameSpace(cop); + CMPIStatus status; struct cim_fan *sptr = NULL; struct fanlist *lptr = NULL, *fans = NULL; @@ -87,9 +88,15 @@ static CMPIStatus LMI_FanAssociatedSensorEnumInstances( LMI_FanAssociatedSensor_Set_Antecedent(&w, &fanSensor); LMI_FanAssociatedSensor_Set_Dependent(&w, &fan); - KReturnInstance(cr, w); + status = __KReturnInstance((cr), &(w).__base); + if (!KOkay(status)) { + free_fanlist(fans); + return status; + } + lptr = lptr->next; } + free_fanlist(fans); CMReturn(CMPI_RC_OK); } diff --git a/src/fan/LMI_FanProvider.c b/src/fan/LMI_FanProvider.c index 26af16e..e01922d 100644 --- a/src/fan/LMI_FanProvider.c +++ b/src/fan/LMI_FanProvider.c @@ -79,6 +79,7 @@ static CMPIStatus LMI_FanEnumInstances( const char** properties) { const char *ns = KNameSpace(cop); + CMPIStatus status; char buf[200]; struct fanlist *lptr = NULL; @@ -189,7 +190,12 @@ static CMPIStatus LMI_FanEnumInstances( LMI_Fan_Set_MaxAlarm(&w, sptr->alarm_max); } - KReturnInstance(cr, w); + status = __KReturnInstance((cr), &(w).__base); + if (!KOkay(status)) { + free_fanlist(fans); + return status; + } + lptr = lptr->next; } free_fanlist(fans); diff --git a/src/fan/LMI_FanSensorProvider.c b/src/fan/LMI_FanSensorProvider.c index e63d266..9b9d750 100644 --- a/src/fan/LMI_FanSensorProvider.c +++ b/src/fan/LMI_FanSensorProvider.c @@ -56,6 +56,7 @@ static CMPIStatus LMI_FanSensorEnumInstances( const CMPIObjectPath* cop, const char** properties) { + CMPIStatus status; char buf[200]; struct cim_fan *sptr = NULL; struct fanlist *lptr = NULL, *fans = NULL; @@ -163,9 +164,16 @@ static CMPIStatus LMI_FanSensorEnumInstances( LMI_FanSensor_Set_MinReadable(&w, 0); LMI_FanSensor_Set_IsLinear(&w, true); - KReturnInstance(cr, w); + status = __KReturnInstance((cr), &(w).__base); + if (!KOkay(status)) { + free_fanlist(fans); + return status; + } + lptr = lptr->next; } + + free_fanlist(fans); CMReturn(CMPI_RC_OK); } |