We increment the pointer for the firmware buffer as we read it, so we
can't free that value. This patch saves the original address so it may
be freed later.
Link: https://github.com/linux-nvme/nvme-cli/issues/304
Fixes: 7151acc
Signed-off-by: Keith Busch <keith.busch@intel.com>
int err, fd, fw_fd = -1;
unsigned int fw_size;
struct stat sb;
- void *fw_buf;
+ void *fw_buf, *buf;
struct config {
char *fw;
err = ENOMEM;
goto close_fw_fd;
}
+
+ buf = fw_buf;
if (cfg.xfer == 0 || cfg.xfer % 4096)
cfg.xfer = 4096;
if (read(fw_fd, fw_buf, fw_size) != ((ssize_t)(fw_size))) {
printf("Firmware download success\n");
free:
- free(fw_buf);
+ free(buf);
close_fw_fd:
close(fw_fd);
close_fd: