core: check n_busses before transmit
Handle the unusual case of no buses - for example with the null binding.
Change-Id: Ia61123d43efa16c5e00fa0f718d4a6206ee6ffae
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/core.c b/core.c
index 0b75cb9..11d4777 100644
--- a/core.c
+++ b/core.c
@@ -332,6 +332,9 @@
static struct mctp_bus *find_bus_for_eid(struct mctp *mctp,
mctp_eid_t dest __attribute__((unused)))
{
+ if (mctp->n_busses == 0)
+ return NULL;
+
/* for now, just use the first bus. For full routing support,
* we will need a table of neighbours */
return &mctp->busses[0];
@@ -803,5 +806,8 @@
struct mctp_bus *bus;
bus = find_bus_for_eid(mctp, eid);
+ if (!bus)
+ return 0;
+
return mctp_message_tx_on_bus(bus, bus->eid, eid, msg, msg_len);
}