pmc_common: Preset uninitialized 'iface.ts_label' with 'iface.name'

pmc_create() calls transport_create(), which sets the open function
for the interface 'iface' to raw_open(), if Layer 2 is used. The
immediate following call of transport_open() calls raw_open(), which
uses the field .ts_label for opening, instead of the field .name
(which is used in the other transport layers). Therefore, the
field .name is copied here into the field .ts_label .

[ RC - Actually ts_label should always be initialized. Made the
       assignment of ts_label unconditional, regardless of the choice
       of transport layer. ]

Signed-off-by: Peter Schneider <peter@psch.de>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Peter Schneider 2018-03-22 00:28:32 +01:00 committed by Richard Cochran
parent f9db6855fd
commit ea9dda30e2
1 changed files with 4 additions and 0 deletions

View File

@ -93,6 +93,10 @@ struct pmc *pmc_create(struct config *cfg, enum transport_type transport_type,
} }
strncpy(iface.name, iface_name, MAX_IFNAME_SIZE); strncpy(iface.name, iface_name, MAX_IFNAME_SIZE);
if (iface.ts_label[0] == '\0') {
strncpy(iface.ts_label, iface.name, MAX_IFNAME_SIZE);
}
if (transport_open(pmc->transport, &iface, if (transport_open(pmc->transport, &iface,
&pmc->fdarray, TS_SOFTWARE)) { &pmc->fdarray, TS_SOFTWARE)) {
pr_err("failed to open transport"); pr_err("failed to open transport");