[libvirt] [PATCHv2] Fix coverity-reported leak in virSecurityManagerGenLabel

Coverity complains about a possible leak of seclabel if !sec_managers[i]->drv->domainGenSecurityLabel is true and the seclabel might be overwritten by the next iteration of the loop. This leak should never happen, because every security driver has domainGenSecurityLabel defined. --- v1: 'Remove useless NULL check in virSecurityManagerGenLabel' https://www.redhat.com/archives/libvir-list/2014-April/msg00087.html src/security/security_manager.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/security/security_manager.c b/src/security/security_manager.c index d68c7e9..79edb07 100644 --- a/src/security/security_manager.c +++ b/src/security/security_manager.c @@ -514,6 +514,8 @@ int virSecurityManagerGenLabel(virSecurityManagerPtr mgr, if (!sec_managers[i]->drv->domainGenSecurityLabel) { virReportUnsupportedError(); + virSecurityLabelDefFree(seclabel); + seclabel = NULL; } else { /* The seclabel must be added to @vm prior calling domainGenSecurityLabel * which may require seclabel to be presented already */ -- 1.8.3.2

On 04/02/2014 07:26 AM, Ján Tomko wrote:
Coverity complains about a possible leak of seclabel if !sec_managers[i]->drv->domainGenSecurityLabel is true and the seclabel might be overwritten by the next iteration of the loop.
This leak should never happen, because every security driver has domainGenSecurityLabel defined. --- v1: 'Remove useless NULL check in virSecurityManagerGenLabel' https://www.redhat.com/archives/libvir-list/2014-April/msg00087.html
ACK, and nicer that it is smaller. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 04/02/2014 04:26 PM, Eric Blake wrote:
On 04/02/2014 07:26 AM, Ján Tomko wrote:
Coverity complains about a possible leak of seclabel if !sec_managers[i]->drv->domainGenSecurityLabel is true and the seclabel might be overwritten by the next iteration of the loop.
This leak should never happen, because every security driver has domainGenSecurityLabel defined. --- v1: 'Remove useless NULL check in virSecurityManagerGenLabel' https://www.redhat.com/archives/libvir-list/2014-April/msg00087.html
ACK, and nicer that it is smaller.
Thanks, now pushed. Jan
participants (2)
-
Eric Blake
-
Ján Tomko