out_cloudwatch_logs: fix log stream leak when group allocation fails - #12257
Open
ParakhJaggi wants to merge 1 commit into
Open
out_cloudwatch_logs: fix log stream leak when group allocation fails#12257ParakhJaggi wants to merge 1 commit into
ParakhJaggi wants to merge 1 commit into
Conversation
In get_or_create_log_stream(), when flb_sds_create() fails for the group name, the function returned without releasing the partially initialised log_stream. Both the struct itself and the already allocated name field were leaked. The branch immediately above, which handles a failed name allocation, frees the struct, and the create_log_stream() failure path below already calls log_stream_destroy(). Only this branch was missing the cleanup. Use log_stream_destroy() here as well. It null checks every field, so it handles the partially initialised struct correctly. This path is only reached when an allocation fails, which is most likely under memory pressure, so the leak compounds exactly when the process can least afford it. Signed-off-by: ParakhJaggi <parakhjaggi@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe CloudWatch log stream creation path now destroys a partially initialized log stream when group-name allocation fails. ChangesCloudWatch log stream creation
Estimated code review effort: 1 (Trivial) | ~5 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In
get_or_create_log_stream(), the branch handling a failedflb_sds_create()for the group name returns without releasing the partially initialisedlog_stream, leaking both the struct and the already allocatednamefield:The asymmetry with the branch directly above, and with the
create_log_stream()failure path below which already callslog_stream_destroy(), suggests this was an oversight rather than intentional.This change uses
log_stream_destroy()in that branch as well. It null checks every field, so it handles the partially initialised struct correctly.The path is only reached when an allocation fails, which in practice means the process is already under memory pressure, so the leak compounds exactly when it can least be afforded.
Enter
[N/A]in the box, if an item is not applicable to your change.Testing
Before we can approve your change; please submit the following in a comment:
If this is a change to packaging of containers or native binaries then please confirm it works for all targets.
ok-package-testlabel to test for all targets (requires maintainer to do).Documentation
Backporting
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.
Summary by CodeRabbit