diff options
author | Michael Olbrich <m.olbrich@pengutronix.de> | 2016-09-16 08:43:38 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2017-03-31 13:57:14 +0200 |
commit | 8722a342bbc95614b2297eb4698769df6e6ca7e2 (patch) | |
tree | 93337c613610b4c9a2fb6596724398077f9d13a3 | |
parent | cc6ad94c3380cde42c464b5ae1a396d18b6d9bb6 (diff) | |
download | dt-utils-8722a342bbc95614b2297eb4698769df6e6ca7e2.tar.gz dt-utils-8722a342bbc95614b2297eb4698769df6e6ca7e2.tar.xz |
state: copy backend of_path string
Caching pointers to device tree nodes or names is not safe. The barebox
internal device tree may be changed by loading a new device tree or through
fixup handlers. As a result, the string may be deleted.
Use local copies of the full path instead.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | src/barebox-state/backend.c | 3 | ||||
-rw-r--r-- | src/barebox-state/state.h | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/src/barebox-state/backend.c b/src/barebox-state/backend.c index 2f2e6df..5235bb0 100644 --- a/src/barebox-state/backend.c +++ b/src/barebox-state/backend.c @@ -164,7 +164,7 @@ int state_backend_init(struct state_backend *backend, struct device_d *dev, if (ret) goto out_free_format; - backend->of_path = of_path; + backend->of_path = xstrdup(of_path); return 0; @@ -185,4 +185,5 @@ void state_backend_free(struct state_backend *backend) state_storage_free(&backend->storage); if (backend->format) state_format_free(backend->format); + free(backend->of_path); } diff --git a/src/barebox-state/state.h b/src/barebox-state/state.h index 48a6785..eb349af 100644 --- a/src/barebox-state/state.h +++ b/src/barebox-state/state.h @@ -86,7 +86,7 @@ struct state_backend_storage { struct state_backend { struct state_backend_format *format; struct state_backend_storage storage; - const char *of_path; + char *of_path; }; struct state { |