net: hinic: fix memory leak when reading function table
[ Upstream commit 4c1f602df8956bc0decdafd7e4fc7eef50c550b1 ]
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:

committed by
Greg Kroah-Hartman

parent
ce605b68db
commit
bb01910763
@@ -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 tag_sml_funcfg_tbl *funcfg_table_elem;
|
||||||
struct hinic_cmd_lt_rd *read_data;
|
struct hinic_cmd_lt_rd *read_data;
|
||||||
u16 out_size = sizeof(*read_data);
|
u16 out_size = sizeof(*read_data);
|
||||||
|
int ret = ~0;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
read_data = kzalloc(sizeof(*read_data), GFP_KERNEL);
|
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) {
|
switch (idx) {
|
||||||
case VALID:
|
case VALID:
|
||||||
return funcfg_table_elem->dw0.bs.valid;
|
ret = funcfg_table_elem->dw0.bs.valid;
|
||||||
|
break;
|
||||||
case RX_MODE:
|
case RX_MODE:
|
||||||
return funcfg_table_elem->dw0.bs.nic_rx_mode;
|
ret = funcfg_table_elem->dw0.bs.nic_rx_mode;
|
||||||
|
break;
|
||||||
case MTU:
|
case MTU:
|
||||||
return funcfg_table_elem->dw1.bs.mtu;
|
ret = funcfg_table_elem->dw1.bs.mtu;
|
||||||
|
break;
|
||||||
case RQ_DEPTH:
|
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:
|
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);
|
kfree(read_data);
|
||||||
|
|
||||||
return ~0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t hinic_dbg_cmd_read(struct file *filp, char __user *buffer, size_t count,
|
static ssize_t hinic_dbg_cmd_read(struct file *filp, char __user *buffer, size_t count,
|
||||||
|
Reference in New Issue
Block a user