Skip to content

Commit

Permalink
util: prevent a panic when creating an fscrypt protector failed
Browse files Browse the repository at this point in the history
Signed-off-by: Niels de Vos <[email protected]>
  • Loading branch information
nixpanic committed Jan 29, 2025
1 parent 72cfaaf commit 003e0b3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion internal/util/fscrypt/fscrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,14 @@ func initializeAndUnlock(
}

protector, err := fscryptactions.CreateProtector(fscryptContext, protectorName, keyFn, owner)
if err != nil {
if err != nil && protector != nil {
log.ErrorLog(ctx, "fscrypt: protector name=%s create failed: %v. reverting.", protectorName, err)
if revertErr := protector.Revert(); revertErr != nil {
return revertErr
}

return err
} else if err != nil {
return err
}

Expand Down

0 comments on commit 003e0b3

Please sign in to comment.