Skip to content

Commit

Permalink
nvme: Fix get-reg command to not use uninitialized value
Browse files Browse the repository at this point in the history
Just return the error with the bar memory free instead.

Signed-off-by: Tokunori Ikegami <[email protected]>
  • Loading branch information
ikegami-t committed Feb 4, 2024
1 parent 87b876f commit 97017a0
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -5431,23 +5431,21 @@ static int get_register_property(int fd, void **pbar, int offset)

err = nvme_get_property(&args);
if (nvme_status_equals(err, NVME_STATUS_TYPE_NVME, NVME_SC_INVALID_FIELD)) {
err = 0;
value = -1;
} else if (err) {
nvme_show_error("get-property: %s", nvme_strerror(errno));
free(bar);
return err;
}

if (nvme_is_64bit_reg(offset))
*(uint64_t *)(bar + offset) = value;
else
*(uint32_t *)(bar + offset) = value;

if (err)
free(bar);
else
*pbar = bar;
*pbar = bar;

return err;
return 0;
}

static int get_register(int argc, char **argv, struct command *cmd, struct plugin *plugin)
Expand Down

0 comments on commit 97017a0

Please sign in to comment.