From: Robert Hancock <hancock@sedsystems.ca>
Date: Tue, 18 Jun 2019 15:53:04 +0000 (-0600)
Subject: disk: part: Don't skip partition init
X-Git-Tag: v2025.01-rc5-pxa1908~2919^2~7
X-Git-Url: http://git.dujemihanovic.xyz/img/html/static/%7B%7B%20%28.OutputFormats.Get?a=commitdiff_plain;h=4edfabd9e40d72480418d4ce39228abd6c0f4f02;p=u-boot.git

disk: part: Don't skip partition init

blk_get_device_by_str was skipping part_init when hw partition 0 was
selected because it is the default. However, this caused issues when
switching to a non-zero partition and then back to partition zero, as
stale data from the wrong partition was returned.

Remove this optimization and call part_init regardless of the selected
partition.

Signed-off-by: Robert Hancock <hancock@sedsystems.ca>
---

diff --git a/disk/part.c b/disk/part.c
index 862078f3e7..f14bc22b6d 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -414,11 +414,10 @@ int blk_get_device_by_str(const char *ifname, const char *dev_hwpart_str,
 #ifdef CONFIG_HAVE_BLOCK_DEVICE
 	/*
 	 * Updates the partition table for the specified hw partition.
-	 * Does not need to be done for hwpart 0 since it is default and
-	 * already loaded.
+	 * Always should be done, otherwise hw partition 0 will return stale
+	 * data after displaying a non-zero hw partition.
 	 */
-	if(hwpart != 0)
-		part_init(*dev_desc);
+	part_init(*dev_desc);
 #endif
 
 cleanup: