clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name micron-utils.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/__w/nvme-cli/nvme-cli/.build-ci -fcoverage-compilation-dir=/__w/nvme-cli/nvme-cli/.build-ci -resource-dir /usr/lib/llvm-19/lib/clang/19 -include /__w/nvme-cli/nvme-cli/.build-ci/nvme-config.h -I nvme.p -I . -I .. -I ccan -I ../ccan -I libnvme/src -I ../libnvme/src -I /usr/include/json-c -D _FILE_OFFSET_BITS=64 -D _GNU_SOURCE -U NDEBUG -internal-isystem /usr/lib/llvm-19/lib/clang/19/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -std=gnu99 -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -analyzer-opt-analyze-headers -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /__w/nvme-cli/nvme-cli/.build-ci/scan-results/2026-06-24-175442-590-1 -x c ../plugins/micron/micron-utils.c
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | #include <string.h> |
| 9 | |
| 10 | #include <libnvme.h> |
| 11 | |
| 12 | #include "micron-utils.h" |
| 13 | #include "util/cleanup.h" |
| 14 | |
| 15 | char *micron_get_ctrl_name(struct libnvme_transport_handle *hdl) |
| 16 | { |
| 17 | const char *name = libnvme_transport_handle_get_name(hdl); |
| 18 | char *ctrl_name = NULL; |
| 19 | |
| 20 | if (libnvme_transport_handle_is_ctrl(hdl)) { |
| 2 | | Assuming the condition is true | |
|
| |
| 21 | ctrl_name = strdup(name); |
| |
| 22 | } else { |
| 23 | const char *p = strlen(name) > 4 ? strchr(name + 4, 'n') : NULL; |
| 24 | |
| 25 | ctrl_name = p ? strndup(name, p - name) : strdup(name); |
| 26 | } |
| 27 | |
| 28 | return ctrl_name; |
| 29 | } |
| 30 | |
| 31 | char *micron_get_ns_name(struct libnvme_transport_handle *hdl) |
| 32 | { |
| 33 | const char *name = libnvme_transport_handle_get_name(hdl); |
| 34 | char *ns_name = NULL; |
| 35 | |
| 36 | if (libnvme_transport_handle_is_ns(hdl)) { |
| 37 | ns_name = strdup(name); |
| 38 | } else { |
| 39 | if (asprintf(&ns_name, "%sn1", name) < 0) |
| 40 | return NULL; |
| 41 | } |
| 42 | |
| 43 | return ns_name; |
| 44 | } |
| 45 | |
| 46 | char *micron_get_ctrl_sysfs_dir( |
| 47 | struct libnvme_global_ctx *ctx, |
| 48 | struct libnvme_transport_handle *hdl) |
| 49 | { |
| 50 | libnvme_ctrl_t c = NULL; |
| 51 | __cleanup_free char *ctrl_name = NULL; |
| 52 | char *sysfs_dir = NULL; |
| 53 | |
| 54 | ctrl_name = micron_get_ctrl_name(hdl); |
| 1 | Calling 'micron_get_ctrl_name' | |
|
| 5 | | Returned allocated memory | |
|
| 55 | if (ctrl_name && libnvme_scan_ctrl(ctx, ctrl_name, &c) == 0) { |
| 6 | | Assuming 'ctrl_name' is non-null | |
|
| 7 | | Assuming the condition is false | |
|
| |
| 56 | sysfs_dir = strdup(libnvme_ctrl_get_sysfs_dir(c)); |
| 57 | libnvme_free_ctrl(c); |
| 58 | } |
| 59 | |
| 60 | return sysfs_dir; |
| 9 | | Potential leak of memory pointed to by 'ctrl_name' |
|
| 61 | } |