Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfa111de

Browse files
committed
kexec,linux,arm64: avoid the dt.LoadFDT API
Signed-off-by: Chris Koch <chrisko@google.com>
1 parent72f8842 commitfa111de

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

‎pkg/boot/linux/load_linux_image.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"errors"
1111
"fmt"
1212
"io"
13+
"math"
1314
"os"
1415

1516
"github.com/u-root/u-root/pkg/boot/image"
@@ -55,9 +56,17 @@ func sanitizeFDT(fdt *dt.FDT) (*dt.Node, error) {
5556
varErrMemmapEmpty=errors.New("memory map is empty or contains no information about system RAM")
5657

5758
funckexecLoadImage(kernel,ramfs*os.File,cmdlinestring,dtb io.ReaderAt) (*kimage,error) {
58-
fdt,err:=dt.LoadFDT(dtb)
59+
varfdt*dt.FDT
60+
varerrerror
61+
// We want to fail when a user-supplied FDT is not parseable, not
62+
// implicitly fall back to some other FDT. Avoid the dt.LoadFDT API.
63+
ifdtb!=nil {
64+
fdt,err=dt.ReadFDT(io.NewSectionReader(dtb,0,math.MaxInt64))
65+
}else {
66+
fdt,err=dt.ReadFile("/sys/firmware/fdt")
67+
}
5968
iferr!=nil {
60-
returnnil,fmt.Errorf("loadFDT(%s)= %w",dtb,err)
69+
returnnil,fmt.Errorf("Read FDT= %w",err)
6170
}
6271
Debug("Loaded FDT: %s",fdt)
6372

‎pkg/boot/linux/load_linux_image_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ func TestKexecLoadImage(t *testing.T) {
312312
{
313313
name:"loadFDT fails",
314314
fdt:closedFile(t),
315-
errs: []error{dt.ErrNoValidReaders},
315+
errs: []error{os.ErrClosed},
316316
},
317317
{
318318
name:"invalid-memmap",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp