Files
containerd/core/mount
Rodrigo Campos 7a19c94d6c core/mount: Don't call nil function on errors
doPrepareIDMappedOverlay() can return nil as the cleanup function. As
the function mandates for the callback to be called, even when errors
are returned, we end-up calling the nil function that of course causes:

        panic: runtime error: invalid memory address or nil pointer dereference

The containerd daemon continues to run fine, though.

With the current structure of always calling the cleanup function, we
would either need to check which error it is, to call it only on
specific errors (ugly) or return a "stub function" that doesn't do
anything on those cases (so the call works). None of these options seem
very nice.

Let's just switch the logic to a pattern more common on go: only need to
cleanup if it returned fine. This makes it easier for callers to not do
the wrong thing.

For this change we need to do the cleanup when returning errors on the
function itself, so the user doesn't need to do it for us.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2025-08-18 07:01:16 -03:00
..
2024-01-17 09:52:12 -08:00
2024-01-17 09:52:12 -08:00
2024-01-17 09:52:12 -08:00
2024-01-17 09:52:12 -08:00
2024-01-17 09:52:12 -08:00