From 6333d540913a71d27b57596ce12e161b00a7534c Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Tue, 9 Nov 2021 15:44:29 +0000 Subject: [PATCH] disk: return the correct ptr from `RootPartition` When we iterate over the partitions to find the root partition, we are getting the partition by value so even if we return a pointer to that then, it is actually a pointer duplicated object. Return the pointer to the actual partition object instead. --- internal/disk/disk.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/disk/disk.go b/internal/disk/disk.go index 79fcb28d3..8bb328ba8 100644 --- a/internal/disk/disk.go +++ b/internal/disk/disk.go @@ -107,13 +107,13 @@ func (pt PartitionTable) FSTabStageOptionsV2() *osbuild2.FSTabStageOptions { // a mountpoint) of the partition table. Nil is returned if there's no such // partition. func (pt PartitionTable) RootPartition() *Partition { - for _, p := range pt.Partitions { + for idx, p := range pt.Partitions { if p.Filesystem == nil { continue } if p.Filesystem.Mountpoint == "/" { - return &p + return &pt.Partitions[idx] } }