Skip to content

Fix a missing s.lock.Unlock() on an error path#2643

Merged
vrothberg merged 1 commit intocontainers:mainfrom
mtrmac:unlock
Nov 28, 2024
Merged

Fix a missing s.lock.Unlock() on an error path#2643
vrothberg merged 1 commit intocontainers:mainfrom
mtrmac:unlock

Conversation

@mtrmac
Copy link
Copy Markdown
Collaborator

@mtrmac mtrmac commented Nov 26, 2024

... and use defer to avoid that bug in the future.

(Split from larger work as an independent piece. Reviewing is easier when ignoring whitespace changes.)

@mtrmac mtrmac added the kind/bug A defect in an existing functionality (or a PR fixing it) label Nov 26, 2024
if uncompressedDigest := options.Cache.UncompressedDigestForTOC(out.TOCDigest); uncompressedDigest != "" {
s.lockProtected.indexToDiffID[options.LayerIndex] = uncompressedDigest
if err := func() error { // A scope for defer
s.lock.Unlock()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this have a defer?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wow, that’s embarrassing. 🤦

Thanks!

... and use defer to avoid that bug in the future.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Copy link
Copy Markdown
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug A defect in an existing functionality (or a PR fixing it)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants