diff mbox series

diskpart: fix crash when diskpart format is not set

Message ID 20211110150234.1229950-1-sbabic@denx.de
State Accepted
Headers show
Series diskpart: fix crash when diskpart format is not set | expand

Commit Message

Stefano Babic Nov. 10, 2021, 3:02 p.m. UTC
If a filesystem should be formatted but no support for filesystem was
compiled, SWUpdate crashes with:

[ERROR] : SWUPDATE failed [0] ERROR : Partitions have fstype entries but diskpart format support is missing !
swupdate: ../util-linux-2.35.1/libfdisk/src/context.c:516: fdisk_get_parent: Assertion `cxt' failed.

Check fdisk context pointer before cleaning up.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 handlers/diskpart_handler.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/handlers/diskpart_handler.c b/handlers/diskpart_handler.c
index e08c10e7..aeae1ad5 100644
--- a/handlers/diskpart_handler.c
+++ b/handlers/diskpart_handler.c
@@ -952,7 +952,8 @@  handler_exit:
 			WARN("Error deassign device %s", img->device);
 
 handler_release:
-	diskpart_unref_context(cxt);
+	if (cxt)
+		diskpart_unref_context(cxt);
 
 	/*
 	 * Kernel rereads the partition table and add just a delay to be sure