aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/dpll
diff options
context:
space:
mode:
authorArkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>2024-01-19 14:43:01 +0100
committerDavid S. Miller <davem@davemloft.net>2024-01-22 11:01:11 +0000
commitb6a11a7fc4d6337f7ea720b9287d1b9749c4eae0 (patch)
tree9e1115554067e0f72b4ca4ba0a9ccdccca2034d5 /drivers/dpll
parentef48521672452aa7a5da1cb91160822eda6e4403 (diff)
downloadlinux-b6a11a7fc4d6337f7ea720b9287d1b9749c4eae0.tar.gz
dpll: fix broken error path in dpll_pin_alloc(..)
If pin type is not expected, or pin properities failed to allocate memory, the unwind error path shall not destroy pin's xarrays, which were not yet initialized. Add new goto label and use it to fix broken error path. Reviewed-by: Jiri Pirko <jiri@nvidia.com> Signed-off-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/dpll')
-rw-r--r--drivers/dpll/dpll_core.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/dpll/dpll_core.c b/drivers/dpll/dpll_core.c
index 1eca8cc271f84..c08772ee9fd69 100644
--- a/drivers/dpll/dpll_core.c
+++ b/drivers/dpll/dpll_core.c
@@ -441,7 +441,7 @@ dpll_pin_alloc(u64 clock_id, u32 pin_idx, struct module *module,
if (WARN_ON(prop->type < DPLL_PIN_TYPE_MUX ||
prop->type > DPLL_PIN_TYPE_MAX)) {
ret = -EINVAL;
- goto err;
+ goto err_pin_prop;
}
pin->prop = prop;
refcount_set(&pin->refcount, 1);
@@ -450,11 +450,12 @@ dpll_pin_alloc(u64 clock_id, u32 pin_idx, struct module *module,
ret = xa_alloc_cyclic(&dpll_pin_xa, &pin->id, pin, xa_limit_32b,
&dpll_pin_xa_id, GFP_KERNEL);
if (ret)
- goto err;
+ goto err_xa_alloc;
return pin;
-err:
+err_xa_alloc:
xa_destroy(&pin->dpll_refs);
xa_destroy(&pin->parent_refs);
+err_pin_prop:
kfree(pin);
return ERR_PTR(ret);
}