summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2025-08-21 15:05:15 -0600
committerTom Rini <trini@konsulko.com>2025-08-21 15:05:15 -0600
commit94e690c44a03959c39f0f5a44a9b89c851af3b60 (patch)
treec7c0be6fc2b81d79794874df35130bbea5e5f6ac
parent0174b3380313ac027cf861d9b8be5721a2a0f103 (diff)
parent498e423457a0360c01d976aa21a218995a1bdef8 (diff)
Merge patch series "bootstd: rauc: Fix segfault when scanning device with unsupported layout"
Martin Schwan <m.schwan@phytec.de> says: This series fixes a segfault, that would occur at the end of scanning a device, which does not contain the required partition layout scheme for a RAUC system. With this series, a "bootflow scan" should now correctly scan the specified devices with boot method "rauc" without crashing on invalid partition schemes. Link: https://lore.kernel.org/r/20250813-wip-bootmeth-rauc-priv-free-v1-0-1ef928169469@phytec.de
-rw-r--r--boot/bootmeth_rauc.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/boot/bootmeth_rauc.c b/boot/bootmeth_rauc.c
index 7c1a895139e..81a73046e83 100644
--- a/boot/bootmeth_rauc.c
+++ b/boot/bootmeth_rauc.c
@@ -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,13 +199,8 @@ 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]->name; i++) {
- free(priv->slots[i]->name);
- free(priv->slots[i]);
- }
- free(priv);
+ distro_rauc_priv_free(priv);
free(boot_order_copy);
- bflow->bootmeth_priv = NULL;
return ret;
}
@@ -402,6 +409,8 @@ static int distro_rauc_boot(struct udevice *dev, struct bootflow *bflow)
if (ret)
return log_msg_ret("boot", ret);
+ distro_rauc_priv_free(priv);
+
return 0;
}