blob: 85e1d3ff3f9fe38c61a90bfb0fa6dd4df14a69c5 [file] [log] [blame]
Andrew Jeffery4fe996c2018-02-27 12:16:48 +10301// SPDX-License-Identifier: Apache-2.0
2// Copyright (C) 2018 IBM Corp.
Cyril Burc85e34d2016-11-15 11:50:41 +11003
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +11004#define _GNU_SOURCE
Cyril Burc85e34d2016-11-15 11:50:41 +11005#include <assert.h>
6#include <errno.h>
7#include <fcntl.h>
8#include <getopt.h>
9#include <limits.h>
10#include <poll.h>
11#include <stdbool.h>
12#include <stdint.h>
13#include <stdio.h>
14#include <stdlib.h>
15#include <string.h>
16#include <syslog.h>
Michael Neuling899ebac2017-01-14 11:20:26 -060017#include <signal.h>
Cyril Burc85e34d2016-11-15 11:50:41 +110018#include <sys/ioctl.h>
19#include <sys/mman.h>
20#include <sys/stat.h>
21#include <sys/timerfd.h>
22#include <sys/types.h>
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +110023#include <sys/signalfd.h>
Cyril Burc85e34d2016-11-15 11:50:41 +110024#include <time.h>
25#include <unistd.h>
Andrew Jeffery78210b92017-01-13 13:06:09 +103026#include <inttypes.h>
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +110027#include <systemd/sd-bus.h>
Cyril Burc85e34d2016-11-15 11:50:41 +110028
Suraj Jitindar Singh8d65bb42017-05-01 16:05:17 +100029#include "config.h"
Andrew Jeffery26558db2018-08-10 00:22:38 +093030#include "mboxd.h"
Cyril Burc85e34d2016-11-15 11:50:41 +110031#include "common.h"
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +110032#include "dbus.h"
Andrew Jeffery55f4d6f2018-08-06 12:26:44 +093033#include "control_dbus.h"
Evan Lojewskif1e547c2019-03-14 14:34:33 +103034#include "backend.h"
Andrew Jefferycd186112018-08-08 10:47:55 +093035#include "lpc.h"
Andrew Jeffery457a6e52018-08-08 11:21:08 +093036#include "transport_mbox.h"
Andrew Jeffery23140be2018-09-05 14:15:07 +093037#include "transport_dbus.h"
Andrew Jefferyf593b1b2018-08-08 11:01:04 +093038#include "windows.h"
Andrew Jeffery53c21aa2018-03-26 11:56:16 +103039#include "vpnor/mboxd_pnor_partition_table.h"
Cyril Burc85e34d2016-11-15 11:50:41 +110040
Evan Lojewskia0429782019-03-13 15:25:44 +103041const char* USAGE =
42 "\nUsage: %s [-V | --version] [-h | --help] [-v[v] | --verbose] [-s | --syslog]\n"
43 "\t\t[-n | --window-num <num>]\n"
44 "\t\t[-w | --window-size <size>M]\n"
45 "\t\t-f | --flash <size>[K|M]\n"
46#ifdef VIRTUAL_PNOR_ENABLED
47 "\t\t-s | --source <vpnor|path>\n\n"
48#else
49 "\t\t-s | --source <path>\n\n"
50#endif
51 "\t-v | --verbose\t\tBe [more] verbose\n"
52 "\t-s | --syslog\t\tLog output to syslog (pointless without -v)\n"
53 "\t-n | --window-num\tThe number of windows\n"
54 "\t\t\t\t(default: fill the reserved memory region)\n"
55 "\t-w | --window-size\tThe window size (power of 2) in MB\n"
56 "\t\t\t\t(default: 1MB)\n"
57 "\t-f | --flash\t\tSize of flash in [K|M] bytes\n\n";
Cyril Burc85e34d2016-11-15 11:50:41 +110058
Andrew Jefferyfe0c9e82018-11-01 14:02:17 +103059static int dbus_init(struct mbox_context *context,
60 const struct transport_ops **ops)
Andrew Jefferyef9e62d2018-08-08 15:48:27 +093061{
62 int rc;
63
64 rc = sd_bus_default_system(&context->bus);
65 if (rc < 0) {
66 MSG_ERR("Failed to connect to the system bus: %s\n",
67 strerror(-rc));
68 return rc;
69 }
70
71 rc = control_legacy_init(context);
72 if (rc < 0) {
73 MSG_ERR("Failed to initialise legacy DBus interface: %s\n",
74 strerror(-rc));
75 return rc;
76 }
77
78 rc = control_dbus_init(context);
79 if (rc < 0) {
80 MSG_ERR("Failed to initialise DBus control interface: %s\n",
81 strerror(-rc));
82 return rc;
83 }
84
Andrew Jefferyfe0c9e82018-11-01 14:02:17 +103085 rc = transport_dbus_init(context, ops);
Andrew Jeffery23140be2018-09-05 14:15:07 +093086 if (rc < 0) {
87 MSG_ERR("Failed to initialise DBus protocol interface: %s\n",
88 strerror(-rc));
89 return rc;
90 }
91
Andrew Jefferyef9e62d2018-08-08 15:48:27 +093092 rc = sd_bus_request_name(context->bus, MBOX_DBUS_NAME,
93 SD_BUS_NAME_ALLOW_REPLACEMENT |
94 SD_BUS_NAME_REPLACE_EXISTING);
95 if (rc < 0) {
Andrew Jeffery23140be2018-09-05 14:15:07 +093096 MSG_ERR("Failed to request DBus name: %s\n", strerror(-rc));
Andrew Jefferyef9e62d2018-08-08 15:48:27 +093097 return rc;
98 }
99
100 rc = sd_bus_get_fd(context->bus);
101 if (rc < 0) {
102 MSG_ERR("Failed to get bus fd: %s\n", strerror(-rc));
103 return rc;
104 }
105
106 context->fds[DBUS_FD].fd = rc;
107
108 return 0;
109}
110
111static void dbus_free(struct mbox_context *context)
112{
Andrew Jeffery23140be2018-09-05 14:15:07 +0930113 transport_dbus_free(context);
Andrew Jefferyef9e62d2018-08-08 15:48:27 +0930114 control_dbus_free(context);
115 control_legacy_free(context);
116 sd_bus_unref(context->bus);
117}
Andrew Jeffery55f4d6f2018-08-06 12:26:44 +0930118
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100119static int poll_loop(struct mbox_context *context)
Cyril Burc85e34d2016-11-15 11:50:41 +1100120{
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100121 int rc = 0, i;
Cyril Bur46233672017-01-16 13:33:26 +1100122
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100123 /* Set POLLIN on polling file descriptors */
124 for (i = 0; i < POLL_FDS; i++) {
125 context->fds[i].events = POLLIN;
Cyril Bur46233672017-01-16 13:33:26 +1100126 }
127
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100128 while (1) {
129 rc = poll(context->fds, POLL_FDS, -1);
130
131 if (rc < 0) { /* Error */
132 MSG_ERR("Error from poll(): %s\n", strerror(errno));
133 break; /* This should mean we clean up nicely */
134 }
135
136 /* Event on Polled File Descriptor - Handle It */
137 if (context->fds[SIG_FD].revents & POLLIN) { /* Signal */
138 struct signalfd_siginfo info = { 0 };
139
140 rc = read(context->fds[SIG_FD].fd, (void *) &info,
141 sizeof(info));
142 if (rc != sizeof(info)) {
143 MSG_ERR("Error reading signal event: %s\n",
144 strerror(errno));
145 }
146
Suraj Jitindar Singh28519592017-04-27 14:48:58 +1000147 MSG_DBG("Received signal: %d\n", info.ssi_signo);
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100148 switch (info.ssi_signo) {
149 case SIGINT:
150 case SIGTERM:
Suraj Jitindar Singh28519592017-04-27 14:48:58 +1000151 MSG_INFO("Caught Signal - Exiting...\n");
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100152 context->terminate = true;
153 break;
154 case SIGHUP:
Andrew Jefferyf69760d2019-03-14 16:54:13 +1030155 rc = protocol_reset(context);
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100156 if (rc < 0) {
Andrew Jefferyf69760d2019-03-14 16:54:13 +1030157 MSG_ERR("Failed to reset on SIGHUP\n");
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100158 }
159 break;
160 default:
161 MSG_ERR("Unhandled Signal: %d\n",
162 info.ssi_signo);
163 break;
164 }
165 }
166 if (context->fds[DBUS_FD].revents & POLLIN) { /* DBUS */
Suraj Jitindar Singh28519592017-04-27 14:48:58 +1000167 while ((rc = sd_bus_process(context->bus, NULL)) > 0) {
168 MSG_DBG("DBUS Event\n");
169 }
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100170 if (rc < 0) {
171 MSG_ERR("Error handling DBUS event: %s\n",
172 strerror(-rc));
173 }
174 }
175 if (context->terminate) {
176 break; /* This should mean we clean up nicely */
177 }
178 if (context->fds[MBOX_FD].revents & POLLIN) { /* MBOX */
Suraj Jitindar Singh28519592017-04-27 14:48:58 +1000179 MSG_DBG("MBOX Event\n");
Andrew Jefferyd86141b2018-08-09 14:58:53 +0930180 rc = transport_mbox_dispatch(context);
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100181 if (rc < 0) {
182 MSG_ERR("Error handling MBOX event\n");
183 }
184 }
185 }
186
Andrew Jefferyf69760d2019-03-14 16:54:13 +1030187 rc = protocol_reset(context);
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100188 if (rc < 0) {
Andrew Jefferyf69760d2019-03-14 16:54:13 +1030189 MSG_ERR("Failed to reset during poll loop cleanup\n");
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100190 }
191
192 return rc;
Cyril Burc85e34d2016-11-15 11:50:41 +1100193}
194
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100195static int init_signals(struct mbox_context *context, sigset_t *set)
Cyril Burc85e34d2016-11-15 11:50:41 +1100196{
197 int rc;
Cyril Burc85e34d2016-11-15 11:50:41 +1100198
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100199 /* Block SIGHUPs, SIGTERMs and SIGINTs */
200 sigemptyset(set);
201 sigaddset(set, SIGHUP);
202 sigaddset(set, SIGINT);
203 sigaddset(set, SIGTERM);
204 rc = sigprocmask(SIG_BLOCK, set, NULL);
205 if (rc < 0) {
206 MSG_ERR("Failed to set SIG_BLOCK mask %s\n", strerror(errno));
207 return rc;
Cyril Burc85e34d2016-11-15 11:50:41 +1100208 }
209
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100210 /* Get Signal File Descriptor */
211 rc = signalfd(-1, set, SFD_NONBLOCK);
212 if (rc < 0) {
213 MSG_ERR("Failed to get signalfd %s\n", strerror(errno));
214 return rc;
Cyril Burc85e34d2016-11-15 11:50:41 +1100215 }
216
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100217 context->fds[SIG_FD].fd = rc;
Cyril Burc85e34d2016-11-15 11:50:41 +1100218 return 0;
219}
220
Cyril Burc85e34d2016-11-15 11:50:41 +1100221static void usage(const char *name)
222{
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100223 printf(USAGE, name);
Cyril Burc85e34d2016-11-15 11:50:41 +1100224}
225
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100226static bool parse_cmdline(int argc, char **argv,
227 struct mbox_context *context)
Cyril Burc85e34d2016-11-15 11:50:41 +1100228{
Cyril Bure8f2de12017-01-17 16:56:02 +1100229 char *endptr;
Suraj Jitindar Singhc29172e2017-04-12 14:26:47 +1000230 int opt;
Cyril Burc85e34d2016-11-15 11:50:41 +1100231
232 static const struct option long_options[] = {
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100233 { "flash", required_argument, 0, 'f' },
Evan Lojewskia0429782019-03-13 15:25:44 +1030234 { "backend", required_argument, 0, 'b' },
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100235 { "window-size", optional_argument, 0, 'w' },
236 { "window-num", optional_argument, 0, 'n' },
237 { "verbose", no_argument, 0, 'v' },
238 { "syslog", no_argument, 0, 's' },
239 { "version", no_argument, 0, 'V' },
240 { "help", no_argument, 0, 'h' },
241 { 0, 0, 0, 0 }
Cyril Burc85e34d2016-11-15 11:50:41 +1100242 };
243
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100244 verbosity = MBOX_LOG_NONE;
Cyril Burc85e34d2016-11-15 11:50:41 +1100245 mbox_vlog = &mbox_log_console;
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100246
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100247 context->current = NULL; /* No current window */
248
Evan Lojewskia0429782019-03-13 15:25:44 +1030249 while ((opt = getopt_long(argc, argv, "f:b:w::n::vsVh", long_options, NULL))
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100250 != -1) {
Cyril Burc85e34d2016-11-15 11:50:41 +1100251 switch (opt) {
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100252 case 0:
253 break;
254 case 'f':
Evan Lojewskif1e547c2019-03-14 14:34:33 +1030255 context->backend.flash_size = strtol(optarg, &endptr, 10);
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100256 if (optarg == endptr) {
257 fprintf(stderr, "Unparseable flash size\n");
258 return false;
259 }
260 switch (*endptr) {
261 case '\0':
Cyril Burc85e34d2016-11-15 11:50:41 +1100262 break;
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100263 case 'M':
Evan Lojewskif1e547c2019-03-14 14:34:33 +1030264 context->backend.flash_size <<= 10;
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100265 case 'K':
Evan Lojewskif1e547c2019-03-14 14:34:33 +1030266 context->backend.flash_size <<= 10;
Cyril Burc85e34d2016-11-15 11:50:41 +1100267 break;
268 default:
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100269 fprintf(stderr, "Unknown units '%c'\n",
270 *endptr);
271 return false;
272 }
273 break;
Evan Lojewskia0429782019-03-13 15:25:44 +1030274 case 'b':
275 context->path = optarg;
276 break;
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100277 case 'n':
278 context->windows.num = strtol(argv[optind], &endptr,
279 10);
280 if (optarg == endptr || *endptr != '\0') {
281 fprintf(stderr, "Unparseable window num\n");
282 return false;
283 }
284 break;
285 case 'w':
286 context->windows.default_size = strtol(argv[optind],
287 &endptr, 10);
288 context->windows.default_size <<= 20; /* Given in MB */
289 if (optarg == endptr || (*endptr != '\0' &&
290 *endptr != 'M')) {
291 fprintf(stderr, "Unparseable window size\n");
292 return false;
293 }
Suraj Jitindar Singh0aff80c2017-04-12 14:37:24 +1000294 if (!is_power_of_2(context->windows.default_size)) {
295 fprintf(stderr, "Window size not power of 2\n");
296 return false;
297 }
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100298 break;
299 case 'v':
300 verbosity++;
301 break;
302 case 's':
303 /* Avoid a double openlog() */
304 if (mbox_vlog != &vsyslog) {
305 openlog(PREFIX, LOG_ODELAY, LOG_DAEMON);
306 mbox_vlog = &vsyslog;
307 }
308 break;
309 case 'V':
Suraj Jitindar Singh8d65bb42017-05-01 16:05:17 +1000310 printf("%s V%s\n", THIS_NAME, PACKAGE_VERSION);
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100311 exit(0);
312 case 'h':
313 return false; /* This will print the usage message */
314 default:
315 return false;
Cyril Burc85e34d2016-11-15 11:50:41 +1100316 }
317 }
318
Evan Lojewskif1e547c2019-03-14 14:34:33 +1030319 if (!context->path) {
320 context->path = get_dev_mtd();
321 }
322 if (!context->backend.flash_size) {
Cyril Bure8f2de12017-01-17 16:56:02 +1100323 fprintf(stderr, "Must specify a non-zero flash size\n");
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100324 return false;
Cyril Bure8f2de12017-01-17 16:56:02 +1100325 }
326
Evan Lojewskif1e547c2019-03-14 14:34:33 +1030327 MSG_INFO("Flash size: 0x%.8x\n", context->backend.flash_size);
Cyril Burc85e34d2016-11-15 11:50:41 +1100328
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100329 if (verbosity) {
Suraj Jitindar Singh28519592017-04-27 14:48:58 +1000330 MSG_INFO("%s logging\n", verbosity == MBOX_LOG_DEBUG ? "Debug" :
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100331 "Verbose");
Cyril Burc85e34d2016-11-15 11:50:41 +1100332 }
333
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100334 return true;
Cyril Burc85e34d2016-11-15 11:50:41 +1100335}
336
Evan Lojewskif1e547c2019-03-14 14:34:33 +1030337static int mboxd_backend_init(struct mbox_context *context)
338{
339 int rc;
340
341#ifdef VIRTUAL_PNOR_ENABLED
342 struct vpnor_partition_paths paths;
343 vpnor_default_paths(&paths);
344
345 rc = backend_probe_vpnor(&context->backend, &paths);
346 if(rc)
347#endif
348 {
349 rc = backend_probe_mtd(&context->backend, context->path);
Evan Lojewskia0429782019-03-13 15:25:44 +1030350 if (rc) {
351 rc = backend_probe_file(&context->backend,
352 context->path);
353 }
Evan Lojewskif1e547c2019-03-14 14:34:33 +1030354 }
355
356 return rc;
357}
358
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100359int main(int argc, char **argv)
360{
Andrew Jefferyfe0c9e82018-11-01 14:02:17 +1030361 const struct transport_ops *mbox_ops, *dbus_ops;
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100362 struct mbox_context *context;
363 char *name = argv[0];
364 sigset_t set;
365 int rc, i;
366
367 context = calloc(1, sizeof(*context));
368 if (!context) {
369 fprintf(stderr, "Memory allocation failed\n");
370 exit(1);
371 }
372
373 if (!parse_cmdline(argc, argv, context)) {
374 usage(name);
375 free(context);
376 exit(0);
377 }
378
379 for (i = 0; i < TOTAL_FDS; i++) {
380 context->fds[i].fd = -1;
381 }
382
Suraj Jitindar Singh28519592017-04-27 14:48:58 +1000383 MSG_INFO("Starting Daemon\n");
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100384
385 rc = init_signals(context, &set);
386 if (rc) {
387 goto finish;
388 }
389
Evan Lojewskif1e547c2019-03-14 14:34:33 +1030390 rc = mboxd_backend_init(context);
391 if (rc) {
392 goto finish;
393 }
394
Andrew Jeffery1e531af2018-08-07 13:32:57 +0930395 rc = protocol_init(context);
396 if (rc) {
397 goto finish;
398 }
399
Andrew Jefferyfe0c9e82018-11-01 14:02:17 +1030400 rc = transport_mbox_init(context, &mbox_ops);
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100401 if (rc) {
402 goto finish;
403 }
404
Andrew Jefferycb9b2102018-08-08 16:31:07 +0930405 rc = lpc_dev_init(context);
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100406 if (rc) {
407 goto finish;
408 }
409
410 /* We've found the reserved memory region -> we can assign to windows */
Andrew Jefferyc1a67fa2018-08-08 17:07:38 +0930411 rc = windows_init(context);
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100412 if (rc) {
413 goto finish;
414 }
415
Andrew Jefferyfe0c9e82018-11-01 14:02:17 +1030416 rc = dbus_init(context, &dbus_ops);
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100417 if (rc) {
418 goto finish;
419 }
420
Deepak Kodihalli017e45c2017-07-12 01:06:30 -0500421 /* Set the LPC bus mapping */
Andrew Jefferyf69760d2019-03-14 16:54:13 +1030422 __protocol_reset(context);
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100423
Andrew Jefferyfe0c9e82018-11-01 14:02:17 +1030424 /* We're ready to go, alert the host */
425 context->bmc_events |= BMC_EVENT_DAEMON_READY;
Andrew Jeffery4c15bb12018-12-05 14:15:28 +1030426 context->bmc_events |= BMC_EVENT_PROTOCOL_RESET;
Andrew Jefferyfe0c9e82018-11-01 14:02:17 +1030427
428 /* Alert on all supported transports */
429 rc = protocol_events_put(context, mbox_ops);
430 if (rc) {
431 goto finish;
432 }
433
434 rc = protocol_events_put(context, dbus_ops);
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100435 if (rc) {
436 goto finish;
437 }
438
Suraj Jitindar Singh28519592017-04-27 14:48:58 +1000439 MSG_INFO("Entering Polling Loop\n");
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100440 rc = poll_loop(context);
441
Suraj Jitindar Singh28519592017-04-27 14:48:58 +1000442 MSG_INFO("Exiting Poll Loop: %d\n", rc);
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100443
444finish:
Suraj Jitindar Singh28519592017-04-27 14:48:58 +1000445 MSG_INFO("Daemon Exiting...\n");
Andrew Jefferyfe0c9e82018-11-01 14:02:17 +1030446 context->bmc_events &= ~BMC_EVENT_DAEMON_READY;
Andrew Jefferyfab672b2018-11-01 17:12:09 +1030447 context->bmc_events |= BMC_EVENT_PROTOCOL_RESET;
Andrew Jefferyfe0c9e82018-11-01 14:02:17 +1030448
449 /* Alert on all supported transports */
450 protocol_events_put(context, mbox_ops);
451 protocol_events_put(context, dbus_ops);
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100452
Andrew Jefferyef9e62d2018-08-08 15:48:27 +0930453 dbus_free(context);
Evan Lojewskif1e547c2019-03-14 14:34:33 +1030454 backend_free(&context->backend);
Andrew Jeffery2e2df282018-08-08 16:32:22 +0930455 lpc_dev_free(context);
Andrew Jeffery55260ce2018-08-09 15:05:59 +0930456 transport_mbox_free(context);
Andrew Jefferyf5f51422018-08-08 17:08:33 +0930457 windows_free(context);
Andrew Jeffery1e531af2018-08-07 13:32:57 +0930458 protocol_free(context);
Suraj Jitindar Singhe39c9162017-03-28 10:47:43 +1100459 free(context);
460
461 return rc;
462}