Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pinctrl: Directly retrieve desired port_binding MAC.
A static analyzer determined that if pb->n_mac was 0, then the c_addrs lport_addresses struct would never be initialized. We would then use and attempt to free uninitialized memory. In reality, pb->n_mac should always be 1. This is because the port binding is a representation of a northbound logical router port. Logical router ports do not contain an array of MACs like the southbound port bindings do. Instead, they have a single MAC string that is always guaranteed to be non-NULL. This string is copied into the port binding's MAC array. Therefore, a southbound port binding that comes from a logical router port will always have n_mac set to 1. How do we know this is a logical router port? The ports iterated over in this function must have IPv6 prefix delegation configured on them. Only northbound logical router ports have this option available. To silence the static analyzer, this change directly retrieves pb->mac[0] instead of iterating over the pb->mac array. As a safeguard, we ensure that the port binding has only one MAC before attempting to access it. This is based on the off chance that something other than northd has inserted the port binding into the southbound database. Reported-at: https://issues.redhat.com/browse/FDP-224 Signed-off-by: Mark Michelson <[email protected]> Acked-by: Han Zhou <[email protected]>
- Loading branch information