From: Simon Glass <sjg@chromium.org> The bootctrl_ui uclass allocates a bc_ui_priv per device, and UI drivers (multiboot_ui, simple_ui) populate upriv->expo via bootflow_menu_setup() or build their own via expo_new() Neither is freed when the device goes away, so the expo and every scene, string and object hung off it are leaked - about 50 KB per logic_tkey run. Add a pre_remove hook on the uclass to destroy the expo and release the autoboot_template abuf. Signed-off-by: Simon Glass <sjg@chromium.org> --- boot/bootctl/bootctl-uclass.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/boot/bootctl/bootctl-uclass.c b/boot/bootctl/bootctl-uclass.c index 756702b3e9a..3f06668a199 100644 --- a/boot/bootctl/bootctl-uclass.c +++ b/boot/bootctl/bootctl-uclass.c @@ -8,8 +8,10 @@ #define LOG_CATEGORY UCLASS_BOOTCTL +#include <abuf.h> #include <bootctl.h> #include <dm.h> +#include <expo.h> #include <bootctl/ui.h> UCLASS_DRIVER(bootctrl) = { @@ -39,9 +41,21 @@ UCLASS_DRIVER(bootctrl_state) = { .per_device_plat_auto = sizeof(struct bootctl_uc_plat), }; +static int bootctl_ui_pre_remove(struct udevice *dev) +{ + struct bc_ui_priv *upriv = dev_get_uclass_priv(dev); + + if (upriv->expo) + expo_destroy(upriv->expo); + abuf_uninit(&upriv->autoboot_template); + + return 0; +} + UCLASS_DRIVER(bootctrl_ui) = { .id = UCLASS_BOOTCTL_UI, .name = "bootctrl_ui", + .pre_remove = bootctl_ui_pre_remove, .per_device_plat_auto = sizeof(struct bootctl_uc_plat), .per_device_auto = sizeof(struct bc_ui_priv), }; -- 2.43.0