bcache-tools: fix potential memoryleak problem in, may_add_item()

In may_add_item(), it will directly return 1 without freeing
variable tmp and closing fd, when the return value of detail_base()
is not equal to 0. In addition, we do not check whether
allocating memory for tmp is successful.

Here, we will check whether malloc() returns NULL, and
will free tmp and close fd when detail_base() fails.

Signed-off-by: Zhiqiang Liu <lzhq28@mail.ustc.edu.cn>
Signed-off-by: Coly Li <colyli@suse.de>
1 file changed