Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rgw: refactor D3nDataCache::d3n_io_write to avoid resource leaks #51501

Closed
wants to merge 1 commit into from

Conversation

vedanshbhartia
Copy link
Contributor

@vedanshbhartia vedanshbhartia commented May 16, 2023

  1. D3nChunkDataInfo was allocated at the beginning of the function on the heap, and was not freed in case of errors. This memory allocation has been moved to where it is being utilised.
  2. cache_file file descriptor was not closed if the write to the file failed. The file close snippet has been moved to the end of the function, and is called if the write fails, or if control flow reaches the end of the function.

Reference: Coverity Defect ID 1510684
https://scan5.scan.coverity.com/reports.htm#v59282/p10114/fileInstanceId=237731707&defectInstanceId=53014748&mergedDefectId=1510684

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows

1. D3nChunkDataInfo was allocated at the beginning of the function on
   the heap, and was not freed in case of errors. This memory allocation
   has been moved to where it is being utilised.
2. cache_file file descriptor was not closed if the write to the file
   failed. The file close snippet has been moved to the end of the function,
   and is called if the write fails, or if control flow reaches the end
   of the function.

Signed-off-by: Vedansh Bhartia <vedanshbhartia@gmail.com>
@vedanshbhartia vedanshbhartia requested a review from a team as a code owner May 16, 2023 04:23
@github-actions github-actions bot added the rgw label May 16, 2023
@vedanshbhartia
Copy link
Contributor Author

@yuvalif Is there any issue in closing the file descriptor after adding cache metadata to the cache map?

@yuvalif
Copy link
Contributor

yuvalif commented May 21, 2023

@vedanshbhartia why did you close the PR?

@mattbenjamin mattbenjamin requested a review from mkogan1 May 21, 2023 14:57
@vedanshbhartia
Copy link
Contributor Author

@vedanshbhartia why did you close the PR?
We decided on a slightly different solution to this problem (using unique_ptr and a custom destructor), and I was not sure whether we would keep this function. I'll make these changes in a while and update the PR.

@vedanshbhartia
Copy link
Contributor Author

Github didn't allow me to reopen this PR, so I've opened a new one at #51648

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants