bootstd: rauc: Move freeing private struct to its own function
authorMartin Schwan <m.schwan@phytec.de>
Wed, 13 Aug 2025 11:54:07 +0000 (13:54 +0200)
committerTom Rini <trini@konsulko.com>
Thu, 21 Aug 2025 21:05:04 +0000 (15:05 -0600)
Move freeing a distro_rauc_priv struct to a new, separate function for
better reuse.

Signed-off-by: Martin Schwan <m.schwan@phytec.de>
Tested-by: Wadim Egorov <w.egorov@phytec.de>
boot/bootmeth_rauc.c

index c8efdce..f781a7f 100644 (file)
@@ -52,6 +52,18 @@ struct distro_rauc_priv {
        struct distro_rauc_slot **slots;
 };
 
+static void distro_rauc_priv_free(struct distro_rauc_priv *priv)
+{
+       int i;
+
+       for (i = 0; priv->slots[i]; i++) {
+               free(priv->slots[i]->name);
+               free(priv->slots[i]);
+       }
+       free(priv->slots);
+       free(priv);
+}
+
 static struct distro_rauc_slot *get_slot(struct distro_rauc_priv *priv,
                                         const char *slot_name)
 {
@@ -187,11 +199,7 @@ static int distro_rauc_read_bootflow(struct udevice *dev, struct bootflow *bflow
 
        ret = distro_rauc_scan_parts(bflow);
        if (ret < 0) {
-               for (i = 0; priv->slots[i]; i++) {
-                       free(priv->slots[i]->name);
-                       free(priv->slots[i]);
-               }
-               free(priv);
+               distro_rauc_priv_free(priv);
                free(boot_order_copy);
                return ret;
        }