It was returning an error value without freeding open fd for the device.
This patch replaces 'return' with 'goto' to free fd.
Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com>
if (posix_memalign((void *)&cntlist, getpagesize(), 0x1000)) {
fprintf(stderr, "can not allocate controller list payload\n");
- return ENOMEM;
+ err = -ENOMEM;
+ goto close_fd;
}
err = nvme_identify_ctrl_list(fd, cfg.namespace_id, cfg.cntid, cntlist);
free(cntlist);
+close_fd:
close(fd);
return err;