Skip to content

Commit 8411881

Browse files
author
Mikhail Dmitrichenko
committed
avoid potential nil ptr deref in image rm
In function rm variable `report` might be initialized as nil as a result of call `registry.ImageEngine().Remove(registry.Context(), args, imageOpts)`. Then, there is a call `registry.SetExitCode(report.ExitCode)` without explicit nil check before. Check `len(rmErrors) > 0` doesn't guarantee that report is a non-nil value. So such call may lead to nil deref. This commit adds check `report` for nil before its dereference. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Mikhail Dmitrichenko <[email protected]>
1 parent 6541fc4 commit 8411881

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

cmd/podman/images/rm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func rm(_ *cobra.Command, args []string) error {
8787
}
8888
}
8989
}
90-
if len(rmErrors) > 0 {
90+
if len(rmErrors) > 0 && report != nil {
9191
registry.SetExitCode(report.ExitCode)
9292
}
9393

0 commit comments

Comments
 (0)