Fix memory leak in kmselement

Change-Id: Icf2336ef11d3147cefc82866fd7c7affabb2dc30