octeontx2-af: Fix memory leak of object buf

Currently the error return path when lfs fails to allocate is not free'ing
the memory allocated to buf. Fix this by adding the missing kfree.

Addresses-Coverity: ("Resource leak")
Fixes: f788409714 ("octeontx2-af: Formatting debugfs entry rsrc_alloc.")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Sunil Goutham <sgoutham@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Colin Ian King 2021-03-23 12:32:45 +00:00 коммит произвёл David S. Miller
Родитель f51d7bf1db
Коммит 9e0a537d06
1 изменённых файлов: 3 добавлений и 1 удалений

Просмотреть файл

@ -253,8 +253,10 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp,
return -ENOSPC; return -ENOSPC;
lfs = kzalloc(lf_str_size, GFP_KERNEL); lfs = kzalloc(lf_str_size, GFP_KERNEL);
if (!lfs) if (!lfs) {
kfree(buf);
return -ENOMEM; return -ENOMEM;
}
off += scnprintf(&buf[off], buf_size - 1 - off, "%-*s", lf_str_size, off += scnprintf(&buf[off], buf_size - 1 - off, "%-*s", lf_str_size,
"pcifunc"); "pcifunc");
for (index = 0; index < BLK_COUNT; index++) for (index = 0; index < BLK_COUNT; index++)