提交 17c19287 编写于 作者: D Dan Carpenter 提交者: Doug Ledford

RDMA/siw: Fix a memory leak in siw_init_cpulist()

The error handling code doesn't free siw_cpu_info.tx_valid_cpus[0].  The
first iteration through the loop is a no-op so this is sort of an off
by one bug.  Also Bernard pointed out that we can remove the NULL
assignment and simplify the code a bit.

Fixes: bdcf26bf ("rdma/siw: network and RDMA core interface")
Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: NBernard Metzler <bmt@zurich.ibm.com>
Reviewed-by: NBernard Metzler <bmt@zurich.ibm.com>
Link: https://lore.kernel.org/r/20190809140904.GB3552@mwandaSigned-off-by: NDoug Ledford <dledford@redhat.com>
上级 e9eec6a5
......@@ -160,10 +160,8 @@ static int siw_init_cpulist(void)
out_err:
siw_cpu_info.num_nodes = 0;
while (i) {
while (--i >= 0)
kfree(siw_cpu_info.tx_valid_cpus[i]);
siw_cpu_info.tx_valid_cpus[i--] = NULL;
}
kfree(siw_cpu_info.tx_valid_cpus);
siw_cpu_info.tx_valid_cpus = NULL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册