Fix memory leak for _buf_.
==10014== HEAP SUMMARY:
==10014== in use at exit: 16 bytes in 1 blocks
==10014== total heap usage: 52 allocs, 51 frees, 15,638 bytes
allocated
==10014==
==10014== Searching for pointers to 1 not-freed blocks
==10014== Checked 70,656 bytes
==10014==
==10014== 16 bytes in 1 blocks are definitely lost in loss record 1 of 1
==10014== at 0x4C2FFC6: memalign (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==10014== by 0x4C300D1: posix_memalign (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==10014== by 0x402733: dir_receive (nvme.c:3531)
==10014== by 0x4192A7: handle_plugin (plugin.c:150)
==10014== by 0x401890: main (nvme.c:3825)
==10014==
==10014== LEAK SUMMARY:
==10014== definitely lost: 16 bytes in 1 blocks
==10014== indirectly lost: 0 bytes in 0 blocks
==10014== possibly lost: 0 bytes in 0 blocks
==10014== still reachable: 0 bytes in 0 blocks
==10014== suppressed: 0 bytes in 0 blocks
==10014==
==10014== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com>
cfg.data_len, dw12, buf, &result);
if (err < 0) {
perror("dir-receive");
- return errno;
+ goto free;
}
if (!err) {
else if (err > 0)
fprintf(stderr, "NVMe Status:%s(%x)\n",
nvme_status_to_string(err), err);
+free:
if (buf)
free(buf);
return err;