Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: bdcf26bf9b3a ("rdma/siw: network and RDMA core interface")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Bernard Metzler <bmt@zurich.ibm.com>
Reviewed-by: Bernard Metzler <bmt@zurich.ibm.com>
Link: https://lore.kernel.org/r/20190809140904.GB3552@mwanda
Signed-off-by: Doug Ledford <dledford@redhat.com>

authored by

Dan Carpenter and committed by
Doug Ledford
17c19287 e9eec6a5

+1 -3
+1 -3
drivers/infiniband/sw/siw/siw_main.c
··· 160 160 161 161 out_err: 162 162 siw_cpu_info.num_nodes = 0; 163 - while (i) { 163 + while (--i >= 0) 164 164 kfree(siw_cpu_info.tx_valid_cpus[i]); 165 - siw_cpu_info.tx_valid_cpus[i--] = NULL; 166 - } 167 165 kfree(siw_cpu_info.tx_valid_cpus); 168 166 siw_cpu_info.tx_valid_cpus = NULL; 169 167