提交 f6f20406 编写于 作者: C Colin Ian King 提交者: Zheng Zengkai

octeontx2-af: Fix memory leak of object buf

stable inclusion
from stable-5.10.27
commit 889c56ea941ed327e037db04b7630f1c85d777df
bugzilla: 51493

--------------------------------

[ Upstream commit 9e0a537d ]

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: f7884097 ("octeontx2-af: Formatting debugfs entry rsrc_alloc.")
Signed-off-by: NColin Ian King <colin.king@canonical.com>
Acked-by: NSunil Goutham <sgoutham@marvell.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: N  Weilong Chen <chenweilong@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 b33aea55
......@@ -163,8 +163,10 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp,
return -ENOSPC;
lfs = kzalloc(lf_str_size, GFP_KERNEL);
if (!lfs)
if (!lfs) {
kfree(buf);
return -ENOMEM;
}
off += scnprintf(&buf[off], buf_size - 1 - off, "%-*s", lf_str_size,
"pcifunc");
for (index = 0; index < BLK_COUNT; index++)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册