mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 01:55:51 +02:00
ice: dpll: fix memory leak in ice_dpll_init_info error paths
Several error return paths in ice_dpll_init_info() directly return
without freeing previously allocated resources, causing memory leaks:
- When de->input_prio allocation fails, d->inputs is leaked
- When dp->input_prio allocation fails, d->inputs and de->input_prio
are leaked
- When ice_get_cgu_rclk_pin_info() fails, all previously allocated
inputs/outputs/input_prio are leaked
- When ice_dpll_init_pins_info(RCLK_INPUT) fails, same resources
are leaked
Fix this by jumping to the deinit_info label which properly calls
ice_dpll_deinit_info() to free all allocated resources.
Fixes: d7999f5ea6 ("ice: implement dpll interface to control cgu")
Signed-off-by: ZhaoJinming <zhaojinming@uniontech.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Tested-by: Rinitha S <sx.rinitha@intel.com> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
This commit is contained in:
parent
a903afff66
commit
20da495f2d
|
|
@ -4752,12 +4752,16 @@ static int ice_dpll_init_info(struct ice_pf *pf, bool cgu)
|
|||
|
||||
alloc_size = sizeof(*de->input_prio) * d->num_inputs;
|
||||
de->input_prio = kzalloc(alloc_size, GFP_KERNEL);
|
||||
if (!de->input_prio)
|
||||
return -ENOMEM;
|
||||
if (!de->input_prio) {
|
||||
ret = -ENOMEM;
|
||||
goto deinit_info;
|
||||
}
|
||||
|
||||
dp->input_prio = kzalloc(alloc_size, GFP_KERNEL);
|
||||
if (!dp->input_prio)
|
||||
return -ENOMEM;
|
||||
if (!dp->input_prio) {
|
||||
ret = -ENOMEM;
|
||||
goto deinit_info;
|
||||
}
|
||||
|
||||
ret = ice_dpll_init_pins_info(pf, ICE_DPLL_PIN_TYPE_INPUT);
|
||||
if (ret)
|
||||
|
|
@ -4782,12 +4786,12 @@ static int ice_dpll_init_info(struct ice_pf *pf, bool cgu)
|
|||
ret = ice_get_cgu_rclk_pin_info(&pf->hw, &d->base_rclk_idx,
|
||||
&pf->dplls.rclk.num_parents);
|
||||
if (ret)
|
||||
return ret;
|
||||
goto deinit_info;
|
||||
for (i = 0; i < pf->dplls.rclk.num_parents; i++)
|
||||
pf->dplls.rclk.parent_idx[i] = d->base_rclk_idx + i;
|
||||
ret = ice_dpll_init_pins_info(pf, ICE_DPLL_PIN_TYPE_RCLK_INPUT);
|
||||
if (ret)
|
||||
return ret;
|
||||
goto deinit_info;
|
||||
de->mode = DPLL_MODE_AUTOMATIC;
|
||||
dp->mode = DPLL_MODE_AUTOMATIC;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user