]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
generic: fitblk: close block device if mapping image failed
authorDaniel Golle <daniel@makrotopia.org>
Fri, 28 Mar 2025 15:40:28 +0000 (15:40 +0000)
committerDaniel Golle <daniel@makrotopia.org>
Fri, 28 Mar 2025 15:42:41 +0000 (15:42 +0000)
In case a broken fit image is present on flash the fitblk driver would
not map any /dev/fit* devices, but also not always close the block device
the image resides on. In case of ubiblock devices this is fatal as one
then cannot remove the ubiblock device (-EBUSY), and hence cannot replace
the broken image.
Always close the block device in case no sub-image was mapped.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
target/linux/generic/pending-6.6/510-block-add-uImage.FIT-subimage-block-driver.patch

index b06c29ffaf18c4f46152f6b21d34c1e7e1d9d02a..5a88631513d696c1697fdd3f2eb814162f130a4a 100644 (file)
@@ -656,7 +656,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
 +              add_fit_subimage_device(bdev, slot++, start_sect, nr_sects, true);
 +      }
 +
-+      if (!found || !slot)
++      if (!slot)
 +              goto out_bootconf;
 +
 +      dev_info(dev, "mapped %u uImage.FIT filesystem sub-image%s as /dev/fit%s%u%s\n",
@@ -675,7 +675,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
 +      kfree(bootconf);
 +      kfree(fit);
 +out_blkdev:
-+      if (!found || ret)
++      if (!slot)
 +              blkdev_put(bdev, &_fitblk_claim_ptr);
 +
 +      return ret;