ana_log = malloc(ana_log_len);
if (!ana_log) {
- perror("malloc");
err = -ENOMEM;
goto close_fd;
}
len = nvme_get_feature_length(NVME_FEAT_FID_HOST_BEHAVIOR, 0,
&len);
- if (posix_memalign(&buf, getpagesize(), len)) {
- fprintf(stderr, "can not allocate feature payload\n");
- errno = ENOMEM;
+ if (posix_memalign(&buf, getpagesize(), len))
return -1;
- }
memset(buf, 0, len);
args.data_len = len,
"Data area 4 unsupported, bit 6 of Log Page Attributes not set\n");
err = -1;
}
- if (err)
- errno = EINVAL;
}
free(buf);
return err;
{
int err;
nvme_effects_log_node_t *node = malloc(sizeof(nvme_effects_log_node_t));
- if (!node) {
- perror("Failed to allocate memory");
+ if (!node)
return;
- }
node->csi = csi;
err = nvme_get_log_cmd_effects(fd, csi, &node->effects);
if (!cfg.log_entries) {
fprintf(stderr, "non-zero log-entries is required param\n");
- errno = EINVAL;
err = -1;
goto close_fd;
}
goto close_fd;
} else if (err) {
fprintf(stderr, "could not identify controller\n");
- errno = ENODEV;
err = -1;
goto close_fd;
}
cfg.log_entries = min(cfg.log_entries, ctrl.elpe + 1);
err_log = calloc(cfg.log_entries, sizeof(struct nvme_error_log_page));
if (!err_log) {
- perror("could not alloc buffer for error log\n");
- errno = ENOMEM;
err = -1;
goto close_fd;
}
log_size = sizeof(__u64) + cfg.log_entries * sizeof(__u16);
pea_log = calloc(log_size, 1);
if (!pea_log) {
- perror("could not alloc buffer for predictable " \
- "latency event agggregate log entries\n");
err = -ENOMEM;
goto close_fd;
}
pevent = calloc(sizeof(*pevent), 1);
if (!pevent) {
- perror("could not alloc buffer for persistent " \
- "event log header\n");
err = -ENOMEM;
goto close_fd;
}
pevent_log_info = nvme_alloc(cfg.log_len, &huge);
if (!pevent_log_info) {
- perror("could not alloc buffer for persistent event log page\n");
err = -ENOMEM;
goto free_pevent;
}
log_size = sizeof(__u64) + cfg.log_entries * sizeof(__u16);
endurance_log = calloc(log_size, 1);
if (!endurance_log) {
- perror("could not alloc buffer for endurance group" \
- " event agggregate log entries\n");
err = -ENOMEM;
goto close_fd;
}
lab_status = calloc(lslplen, 1);
if (!lab_status) {
- perror("could not alloc buffer for lba status log");
err = -ENOMEM;
goto close_fd;
}
if (!cfg.file_name) {
fprintf(stderr, "Please provide an output file!\n");
- errno = EINVAL;
err = -1;
goto close_fd;
}
if (cfg.lsp > 128) {
fprintf(stderr, "invalid lsp param: %u\n", cfg.lsp);
- errno = EINVAL;
err = -1;
goto close_fd;
}
bpsz = (boot.bpinfo & 0x7fff) * 128 * 1024;
bp_log = calloc(sizeof(boot) + bpsz, 1);
if (!bp_log) {
- perror("could not alloc buffer for boot partition log");
- errno = ENOMEM;
err = -1;
goto close_output;
}
}
if (posix_memalign((void *)&endgrp_list, getpagesize(), 0x1000)) {
- fprintf(stderr, "can not allocate memory for endurance gropu list\n");
- errno = ENOMEM;
err = -1;
goto close_fd;
}
}
if (posix_memalign(&nsdescs, getpagesize(), 0x1000)) {
- fprintf(stderr, "can not allocate controller list payload\n");
err = -ENOMEM;
goto close_fd;
}
if (cfg->data_len) {
if (posix_memalign(buf, getpagesize(), cfg->data_len)) {
- fprintf(stderr, "can not allocate feature payload\n");
- errno = ENOMEM;
return -1;
}
memset(*buf, 0, cfg->data_len);
if (cfg.uuid_index > 128) {
fprintf(stderr, "invalid uuid index param: %u\n", cfg.uuid_index);
- errno = EINVAL;
err = -1;
goto close_fd;
}
fw_buf = nvme_alloc(fw_size, &huge);
if (!fw_buf) {
- perror("No memory for f/w size:\n");
err = -ENOMEM;
goto close_fw_fd;
}
if (cfg.uuid_index > 128) {
fprintf(stderr, "invalid uuid index param: %u\n", cfg.uuid_index);
- errno = EINVAL;
err = -1;
goto close_fd;
}
buffer = nvme_alloc(buffer_size, &huge);
if (!buffer) {
- perror("can not allocate io payload\n");
err = -ENOMEM;
goto close_mfd;
}
}
mbuffer = malloc(mbuffer_size);
if (!mbuffer) {
- perror("can not allocate buf for io metadata payload\n");
err = -ENOMEM;
goto free_buffer;
}
buf_len = (cfg.mndw + 1) * 4;
buf = calloc(1, buf_len);
if (!buf) {
- perror("could not alloc memory for get lba status");
err = -ENOMEM;
goto close_fd;
}
if (cfg.operation > 0xf) {
fprintf(stderr, "invalid operation field: %u\n", cfg.operation);
- errno = EINVAL;
err = -1;
goto close_fd;
}
/* check for input arguement limit */
if (cfg.ifc > 3) {
fprintf(stderr, "invalid interface settings:%d\n", cfg.ifc);
- errno = EINVAL;
err = -1;
goto close_fd;
}
if (cfg.prhbt > 1) {
fprintf(stderr, "invalid prohibit settings:%d\n", cfg.prhbt);
- errno = EINVAL;
err = -1;
goto close_fd;
}
if (cfg.scp > 15) {
fprintf(stderr, "invalid scope settings:%d\n", cfg.scp);
- errno = EINVAL;
err = -1;
goto close_fd;
}
if (cfg.uuid > 127) {
fprintf(stderr, "invalid UUID index settings:%d\n", cfg.uuid);
- errno = EINVAL;
err = -1;
goto close_fd;
}
if (cfg.metadata_len) {
mdata = malloc(cfg.metadata_len);
if (!mdata) {
- perror("can not allocate mdata payload\n");
err = -ENOMEM;
goto close_wfd;
}
if (cfg.data_len) {
data = nvme_alloc(cfg.data_len, &huge);
if (!data) {
- perror("can not allocate data payload\n");
err = -ENOMEM;
goto free_metadata;
}