[PATCH 3/7] bootchooser: avoid a use after free

Juergen Borleis jbe at pengutronix.de
Tue Aug 15 06:46:32 PDT 2017


Signed-off-by: Juergen Borleis <jbe at pengutronix.de>
---
 common/bootchooser.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/bootchooser.c b/common/bootchooser.c
index 455f290fa..69d980d6f 100644
--- a/common/bootchooser.c
+++ b/common/bootchooser.c
@@ -376,9 +376,9 @@ struct bootchooser *bootchooser_get(void)
 			bc->state_prefix = xstrdup(state_prefix);
 			bc->state = state_by_name(state_devname);
 			if (!bc->state) {
-				free(state_devname);
 				pr_err("Cannot get state '%s'\n",
 				       state_devname);
+				free(state_devname);
 				ret = -ENODEV;
 				goto err;
 			}
-- 
2.11.0




More information about the barebox mailing list