summaryrefslogtreecommitdiffstats
path: root/src/nvme/linux.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvme/linux.c')
-rw-r--r--src/nvme/linux.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/nvme/linux.c b/src/nvme/linux.c
index 163086e..e29d9e7 100644
--- a/src/nvme/linux.c
+++ b/src/nvme/linux.c
@@ -124,7 +124,7 @@ int nvme_fw_download_seq(int fd, __u32 size, __u32 xfer, __u32 offset,
int nvme_get_telemetry_max(int fd, enum nvme_telemetry_da *da, size_t *data_tx)
{
- _cleanup_free_ struct nvme_id_ctrl *id_ctrl;
+ _cleanup_free_ struct nvme_id_ctrl *id_ctrl = NULL;
int err;
id_ctrl = __nvme_alloc(sizeof(*id_ctrl));
@@ -385,7 +385,7 @@ int nvme_namespace_detach_ctrls(int fd, __u32 nsid, __u16 num_ctrls,
int nvme_get_ana_log_len(int fd, size_t *analen)
{
- _cleanup_free_ struct nvme_id_ctrl *ctrl;
+ _cleanup_free_ struct nvme_id_ctrl *ctrl = NULL;
int ret;
ctrl = __nvme_alloc(sizeof(*ctrl));
@@ -405,7 +405,7 @@ int nvme_get_ana_log_len(int fd, size_t *analen)
int nvme_get_logical_block_size(int fd, __u32 nsid, int *blksize)
{
- _cleanup_free_ struct nvme_id_ns *ns;
+ _cleanup_free_ struct nvme_id_ns *ns = NULL;
__u8 flbas;
int ret;
@@ -426,7 +426,7 @@ int nvme_get_logical_block_size(int fd, __u32 nsid, int *blksize)
static int __nvme_set_attr(const char *path, const char *value)
{
- _cleanup_fd_ int fd;
+ _cleanup_fd_ int fd = -1;
fd = open(path, O_WRONLY);
if (fd < 0) {
@@ -725,7 +725,7 @@ int nvme_gen_dhchap_key(char *hostnqn, enum nvme_hmac_alg hmac,
unsigned char *key)
{
const char hmac_seed[] = "NVMe-over-Fabrics";
- _cleanup_hmac_ctx_ HMAC_CTX *hmac_ctx;
+ _cleanup_hmac_ctx_ HMAC_CTX *hmac_ctx = NULL;
const EVP_MD *md;
ENGINE_load_builtin_engines();
@@ -881,7 +881,7 @@ int nvme_gen_dhchap_key(char *hostnqn, enum nvme_hmac_alg hmac,
{
const char hmac_seed[] = "NVMe-over-Fabrics";
OSSL_PARAM params[2], *p = params;
- _cleanup_ossl_lib_ctx_ OSSL_LIB_CTX *lib_ctx;
+ _cleanup_ossl_lib_ctx_ OSSL_LIB_CTX *lib_ctx = NULL;
_cleanup_evp_mac_ctx_ EVP_MAC_CTX *mac_ctx = NULL;
_cleanup_evp_mac_ EVP_MAC *mac = NULL;
char *progq = NULL;
@@ -1104,6 +1104,11 @@ static size_t nvme_identity_len(int hmac, int version, const char *hostnqn,
{
size_t len;
+ if (!hostnqn || !subsysnqn) {
+ errno = EINVAL;
+ return -1;
+ }
+
len = strlen(hostnqn) + strlen(subsysnqn) + 12;
if (version == 1) {
len += 66;