summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2010-08-21 17:00:20 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2010-08-30 20:57:20 +0200
commit86086c5faafb8ac8d00b4edbbf51de5fbe03b6b9 (patch)
tree9950b8b9200d0426f760d28d6e41f89246735368
parent6ce1c664deedc932093d2750c37f509b067bf551 (diff)
downloadbarebox-86086c5faafb8ac8d00b4edbbf51de5fbe03b6b9.tar.gz
menu: initialize entries list in menu_alloc
Otherwise menu_free fails when menu_add failed. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--common/menu.c4
-rw-r--r--include/menu.h9
2 files changed, 8 insertions, 5 deletions
diff --git a/common/menu.c b/common/menu.c
index b201644..9c40365 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -68,10 +68,6 @@ int menu_add(struct menu *m)
list_add_tail(&m->list, &menus.list);
- m->nb_entries = 0;
-
- INIT_LIST_HEAD(&m->entries.list);
-
return 0;
}
diff --git a/include/menu.h b/include/menu.h
index 4405ced..128d671 100644
--- a/include/menu.h
+++ b/include/menu.h
@@ -55,7 +55,14 @@ struct menu {
*/
static inline struct menu* menu_alloc(void)
{
- return calloc(1, sizeof(struct menu));
+ struct menu *m;
+
+ m = calloc(1, sizeof(struct menu));
+ if (m) {
+ INIT_LIST_HEAD(&m->entries.list);
+ m->nb_entries = 0;
+ }
+ return m;
}
void menu_free(struct menu *m);
int menu_add(struct menu* m);