Skip to content

Commit

Permalink
Coverity issues in contrail-controller/agent
Browse files Browse the repository at this point in the history
- leaked_storage: Variable key going out of scope leaks the storage
it points to in vm_interface_config.cc:VmiProcessConfig
Must free key and data if data->device_type_ is
VmInterface::REMOTE_VM_VLAN_ON_VMI.
- leaked_storage: Variable pkt_handler going out of scope leaks the
storage it points to in segment_health_check.cc:SendRequest
Must free pkt_handler if service_mode is VmInterface::SERVICE_MODE_ERROR.
- bad_memset: Function memset with fill value '0' (the zero character)
in bgp_as_service.cc:BingBgpAsAServicePorts.cc
Correct is 0 instead of '0'.
- leaked_storage: Variable data going out of scope leaks the storage it
points to in nexthop_client.cc:WriteMessage
Actually, data is freed, but it needs to be freed by calling delete [] data
instead of free(data), because it was previsouly allocated by calling new[].

Change-Id: Ibbb94df3ac0fa4ef41789137aed4dc15fa4b3e84
Closes-Bug: #1770193
Signed-off-by: Anda Nicolae <anicolae@lenovo.com>
  • Loading branch information
Anda Nicolae committed May 9, 2018
1 parent ca90a5d commit 32e41cc
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/vnsw/agent/diag/segment_health_check.cc
Expand Up @@ -110,6 +110,7 @@ void SegmentHealthCheckPkt::SendRequest() {
bool l3_mode = false;
MacAddress dest_mac;
if (service_mode == VmInterface::SERVICE_MODE_ERROR) {
delete pkt_handler;
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/vnsw/agent/nexthop_server/nexthop_client.cc
Expand Up @@ -145,6 +145,6 @@ NexthopDBClient::WriteMessage()
* Send always succeeds
*/
session_->Send(data, data_len);
free(data);
delete [] data;
}
}
2 changes: 1 addition & 1 deletion src/vnsw/agent/oper/bgp_as_service.cc
Expand Up @@ -60,7 +60,7 @@ void BgpAsAService::BindBgpAsAServicePorts(const std::vector<uint16_t> &ports) {
for (uint16_t port = start; port <= end; port++) {
int port_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
struct sockaddr_in address;
memset(&address, '0', sizeof(address));
memset(&address, 0, sizeof(address));
address.sin_family = AF_INET;
address.sin_addr.s_addr = htonl(agent_->router_id().to_ulong());
address.sin_port = htons(port);
Expand Down
2 changes: 2 additions & 0 deletions src/vnsw/agent/oper/vm_interface_config.cc
Expand Up @@ -1670,6 +1670,8 @@ bool InterfaceTable::VmiProcessConfig(IFMapNode *node, DBRequest &req,
if (data->device_type_ == VmInterface::REMOTE_VM_VLAN_ON_VMI &&
(rx_vlan_id == VmInterface::kInvalidVlanId ||
tx_vlan_id == VmInterface::kInvalidVlanId)) {
req.key.reset(key);
req.data.reset(data);
return false;
}

Expand Down

0 comments on commit 32e41cc

Please sign in to comment.