Skip to content

Fixing Memory Leak#50

Merged
keithbusch merged 1 commit intolinux-nvme:masterfrom
lakshminarayanand:nvme-cli-local
Jan 21, 2016
Merged

Fixing Memory Leak#50
keithbusch merged 1 commit intolinux-nvme:masterfrom
lakshminarayanand:nvme-cli-local

Conversation

@lakshminarayanand
Copy link
Contributor

In submit_io buffers "buffer and mbuffer" allocated are not getting freed at the fail cases and hence might lead to memory leak
This patch free the buffer before the return of the function .

@keithbusch
Copy link
Contributor

Being a user space application that typically executes on the order of milliseconds, we got a bit lazy with resource management and let the operating system reclaim memory and file descriptors when the program closes.

Cleaning up that sloppiness is a good idea. Maybe this program will add an interactive mode in the future where resource management will be more important.

keithbusch pushed a commit that referenced this pull request Jan 21, 2016
@keithbusch keithbusch merged commit 2a1630b into linux-nvme:master Jan 21, 2016
ikegami-t pushed a commit to ikegami-t/nvme-cli that referenced this pull request Aug 18, 2023
Add nvme_identify_active_ns_list_csi() and nvme_identify_allocated_ns…
jimmunn pushed a commit to Micron-TPG-OSS/nvme-cli that referenced this pull request Feb 23, 2026
…OCTLs (linux-nvme#50)

* Broke methods with Linux ioctl calls into linux-specific implementation file and added stubs for Windows implementations.

* Added admin command stubs for supported commands.

* Initial implementation of nvme_submit_admin_identify.

Compiles. Untested.

* Removed ioctl stub function from platform_windows.h

Any ioctl calls need to be handled by Windows-specific code.  Current libnvme ioctl calls have been moved into ioctl-linux.c/ioctl-windows.c, so the ioctl stub in platform_windows.h is no longer needed.

* Added initial implementation of nvme_submit_admin_vendor_unique (passthrough)

* Pulled command initialization out of loop and additional cleanup.

* Added Get Log Page implementation.

* Updates for format_cmd direct ioctl calls.

- Calling nvme_ns_rescan instead of direct NVME_IOCTL_RESCAN ioctl call.
- Restored ioctl stub in platform/windows.h as temporary workaround for direct BLKBSZSET and BLKRRPART ioctl calls.
- Updated TODO.md entry for ioctl stub to note what will be needed to get rid of the stub.

* Implemented get features command.

* Implemented Set Features command.

* Removed unsupported SubValue5 setting.

* Implemented FW Download.  Several TODO comments left that require verification.

* Added FW commit implementation.

* Fixed security receive check and method name.

* Added security send/receive implementations.

* Implement self test and sanitize using storage protocol command pass-through.

* Format NVM implemented as much as possible based on documentation.

* Cleanup and fixes.

* Removing unrelated changes to ioctl usage in nvme.c.  Saving for a separate PR.

* REmoving unneccesary .gitignore change.

* Fixed checkpatch errors and explicitly added windows includes.

* Fixed identify CSI check.

* Checking SCSI command status after IOCTL_SCSI_PASS_THROUGH

* Handling data direction of storage protocol passthrough commands and added some more error checking.

* Fixed opening brace formatting reported by checkpatch.

* Fixing checkpatch formatting warnings where feasible.

* More minor checkpatch fixes.

* Removed HANDLE casts and switched to using hdl->fd directly.

A recent change that was merged in updated the type of nvme_transport_handle::fd on Windows builds to be HANDLE, so casting the value and storing it in a new variable was no longer necessary.

* Update ioctl-linux.c to align with upstream changes.

Co-authored-by: Brandon Capener <bcapener@micron.com>

* Moving linux implementations back into main ioctl.c.

To make merges from upstream easier for now, leaving linux-specific implementations where they are, but inside of #ifndef _WIN32 blocks.  Eventually we will probably pull these out again.

---------

Co-authored-by: Brandon Capener <bcapener@micron.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants