net: hinic: fix memory leak when reading function table
[ Upstream commit4c1f602df8
] When the input parameter idx meets the expected case option in hinic_dbg_get_func_table(), read_data is not released. Fix it. Fixes:5215e16244
("hinic: add support to query function table") Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Родитель
62aa78a0c3
Коммит
e6765fe8de
|
@ -85,6 +85,7 @@ static int hinic_dbg_get_func_table(struct hinic_dev *nic_dev, int idx)
|
|||
struct tag_sml_funcfg_tbl *funcfg_table_elem;
|
||||
struct hinic_cmd_lt_rd *read_data;
|
||||
u16 out_size = sizeof(*read_data);
|
||||
int ret = ~0;
|
||||
int err;
|
||||
|
||||
read_data = kzalloc(sizeof(*read_data), GFP_KERNEL);
|
||||
|
@ -111,20 +112,25 @@ static int hinic_dbg_get_func_table(struct hinic_dev *nic_dev, int idx)
|
|||
|
||||
switch (idx) {
|
||||
case VALID:
|
||||
return funcfg_table_elem->dw0.bs.valid;
|
||||
ret = funcfg_table_elem->dw0.bs.valid;
|
||||
break;
|
||||
case RX_MODE:
|
||||
return funcfg_table_elem->dw0.bs.nic_rx_mode;
|
||||
ret = funcfg_table_elem->dw0.bs.nic_rx_mode;
|
||||
break;
|
||||
case MTU:
|
||||
return funcfg_table_elem->dw1.bs.mtu;
|
||||
ret = funcfg_table_elem->dw1.bs.mtu;
|
||||
break;
|
||||
case RQ_DEPTH:
|
||||
return funcfg_table_elem->dw13.bs.cfg_rq_depth;
|
||||
ret = funcfg_table_elem->dw13.bs.cfg_rq_depth;
|
||||
break;
|
||||
case QUEUE_NUM:
|
||||
return funcfg_table_elem->dw13.bs.cfg_q_num;
|
||||
ret = funcfg_table_elem->dw13.bs.cfg_q_num;
|
||||
break;
|
||||
}
|
||||
|
||||
kfree(read_data);
|
||||
|
||||
return ~0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t hinic_dbg_cmd_read(struct file *filp, char __user *buffer, size_t count,
|
||||
|
|
Загрузка…
Ссылка в новой задаче