Skip to content

Commit 430b258

Browse files
committed
fix(emulation): avoid nil pointer dereference in registeredBinfmtMisc
When `/proc/sys/fs/binfmt_misc` is not mounted, filepath.WalkDir may pass a nil DirEntry. This caused podman info to panic. Add a nil check to avoid dereferencing it. Signed-off-by: Peiyuan Song <[email protected]>
1 parent b6d92f7 commit 430b258

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pkg/emulation/binfmtmisc_linux.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ func registeredBinfmtMisc() ([]string, error) {
2727
if filepath.Base(path) == "register" { // skip this one
2828
return nil
2929
}
30-
if err != nil && !errors.Is(err, os.ErrNotExist) {
30+
if err != nil {
31+
if errors.Is(err, fs.ErrNotExist) {
32+
return nil
33+
}
3134
return err
3235
}
3336
info, err := d.Info()

0 commit comments

Comments
 (0)