diff options
author | Michael Olbrich <m.olbrich@pengutronix.de> | 2016-09-16 08:43:38 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2016-09-20 10:28:46 +0200 |
commit | 872e6069d59dfa2b6f73d5c6795d50a721ab625e (patch) | |
tree | 2286841ecb33af9dd64954ad5b2258472b375a59 /common/state/backend.c | |
parent | 9cd9d98300af3039db7f146a47914baef2e8ea1b (diff) | |
download | barebox-872e6069d59dfa2b6f73d5c6795d50a721ab625e.tar.gz barebox-872e6069d59dfa2b6f73d5c6795d50a721ab625e.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>
Diffstat (limited to 'common/state/backend.c')
-rw-r--r-- | common/state/backend.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/common/state/backend.c b/common/state/backend.c index 2f2e6dfd32..5235bb0283 100644 --- a/common/state/backend.c +++ b/common/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); } |