s390-tools/s390-tools-pvimg-info-command-02.patch
Nikolay Gueorguiev d7162287c1 - Upgrade s390-tools to 2.37 (jsc#PED-9591, jsc#PED-10303, jesc#PED-11870 (jsc#IBM-1062))
* Changes of existing tools:
    dbginfo.sh: Add details on CPU-measurement
    dbginfo.sh: Add new crypto command
    dbginfo.sh: Add overview commands and crypto update
    dbginfo.sh: Adding kdump info
    dbginfo.sh: Removing outdated email references
    dbginfo.sh: Rework network section
    dbginfo.sh: Update copyright 2nd year
    pvimg: Add '--(enable|disable)-image-encryption' flags to 'pvimg create'
    pvimg: Add '--cck ' command line option and make '--comm-key' an alias
    pvimg: Add '--hdr-key' command line option to 'pvimg create'
    pvimg: Rename '--key' into '--hdr-key' and use '--key' as an alias (for 'pvimg info')
    pvsecret: Add support for retrievable secrets
    ziorep_config: Add PCHID field to adapter report
    ziorep_traffic: Add DEVBUSID column to traffic report
    ziorep_utilization: Add --fcp-device parameter to print virtual adapter report
    ziorep_utilization: Add PCHID column to physical adapter report
    ziorep_utilization: Now prints only physical adapter report by default
    ziorep_utilization: Swap Bus-ID and CHPID columns in virtual adapter report
    zipl/boot: Increase section size for eckd_mv dumper
    zkey: Add support for listing and importing protected virtualization secrets
  * Bug Fixes:
    chpstat: Fix invalid utilization data on older kernels
    opticsmon: Fix runaway loop in on_link_change()
    zipl: Update inline assembly for GCC 15
    zipl_helper.device-mapper: Add missed step in logical device resolution
- Revendored vendor.tar.gz
- Removed obsolete patches:
  * s390-tools-01-zipl_helper.device-mapper-add-missed-step-in-logical.patch
  * s390-tools-02-zipl-src-fix-imprecise-check-that-file-is-on-specifi.patch
  * s390-tools-General-update-01.patch
  * s390-tools-General-update-02.patch
  * s390-tools-General-update-03.patch
  * s390-tools-General-update-04.patch
  * s390-tools-General-update-05.patch
  * s390-tools-General-update-06.patch
  * s390-tools-General-update-07.patch
  * s390-tools-General-update-08.patch
  * s390-tools-General-update-09.patch
  * s390-tools-General-update-10.patch
  * s390-tools-General-update-11.patch
  * s390-tools-General-update-12.patch
  * s390-tools-Additional-update-01.patch
  * s390-tools-Additional-update-02.patch
  * s390-tools-pvimg-info-command-01.patch
  * s390-tools-pvimg-info-command-02.patch
  * s390-tools-pvimg-info-command-03.patch
  * s390-tools-Support-unencrypted-SE-images-01.patch
  * s390-tools-pvimg-info-command-04.patch
  * s390-tools-pvimg-additional-01.patch
  * s390-tools-01-zkey-Add-support-for-retrieving-a-list-of-ultravisor-secrets.patch
  * s390-tools-02-zkey-Add-the--pvsecrets-list-command.patch
  * s390-tools-03-zkey-Add-PVSECRETS-AES-key-type.patch
  * s390-tools-04-zkey-Add-the-pvsecrets-import-command.patch
  * s390-tools-05-zkey-Reject-key-generation-and-APQN-association-for-PVSECRET-AES-keys.patch
  * s390-tools-06-zkey-Reject-re-enciphering-of-PVSECRET-AES-keys.patch
  * s390-tools-07-zkey-Support-validation-of-key-of-type-PVSECRET-AES.patch
  * s390-tools-08-rust-pvimg-Fix-flag-parsing-for-allowing-dump.patch
  * s390-tools-09-rust-pvimg-Document-the-change-from--comm-key-to--cck.patch

OBS-URL: https://build.opensuse.org/package/show/Base:System/s390-tools?expand=0&rev=249
2025-02-10 08:51:00 +00:00

52 lines
2.1 KiB
Diff

From 3f6572e901ddcc654021c4302cb2a99999acb87a Mon Sep 17 00:00:00 2001
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Date: Wed, 18 Dec 2024 13:41:13 +0100
Subject: [PATCH] rust/utils: mkdtemp: fix memory leak
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Fix memory leak of @template_raw. The documentation of CString::into_raw
reads:
"Consumes the CString and transfers ownership of the string to a C
caller.
...
Failure to call CString::from_raw will lead to a memory leak." [1]
Let's fix the memory leak by always calling `CString::from_raw` and
therefore reclaim the ownership.
[1] https://doc.rust-lang.org/std/ffi/struct.CString.html#method.into_raw
Fixes: e56acf4f14b0 ("pv_core: add `TemporaryDirectory`")
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
---
rust/utils/src/tmpfile.rs | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/rust/utils/src/tmpfile.rs b/rust/utils/src/tmpfile.rs
index 07acdba8..883d5586 100644
--- a/rust/utils/src/tmpfile.rs
+++ b/rust/utils/src/tmpfile.rs
@@ -16,13 +16,14 @@ fn mkdtemp<P: AsRef<Path>>(template: P) -> Result<PathBuf, std::io::Error> {
// SAFETY: template_raw is a valid CString because it was generated by
// the `CString::new`.
let ret = libc::mkdtemp(template_raw);
+ // SAFETY: `template_raw` is still a valid CString because it was
+ // generated by `CString::new` and modified by `libc::mkdtemp`.
+ let path_cstr = std::ffi::CString::from_raw(template_raw);
if ret.is_null() {
+ drop(path_cstr);
Err(std::io::Error::last_os_error())
} else {
- // SAFETY: `template_raw` is still a valid CString because it was
- // generated by `CString::new` and modified by `libc::mkdtemp`.
- let path_cstr = std::ffi::CString::from_raw(template_raw);
let path = OsStr::from_bytes(path_cstr.as_bytes());
let path = std::path::PathBuf::from(path);