Skip to content

Commit b6a11a7

Browse files
kubalewskidavem330
authored andcommitted
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>
1 parent ef48521 commit b6a11a7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/dpll/dpll_core.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ dpll_pin_alloc(u64 clock_id, u32 pin_idx, struct module *module,
441441
if (WARN_ON(prop->type < DPLL_PIN_TYPE_MUX ||
442442
prop->type > DPLL_PIN_TYPE_MAX)) {
443443
ret = -EINVAL;
444-
goto err;
444+
goto err_pin_prop;
445445
}
446446
pin->prop = prop;
447447
refcount_set(&pin->refcount, 1);
@@ -450,11 +450,12 @@ dpll_pin_alloc(u64 clock_id, u32 pin_idx, struct module *module,
450450
ret = xa_alloc_cyclic(&dpll_pin_xa, &pin->id, pin, xa_limit_32b,
451451
&dpll_pin_xa_id, GFP_KERNEL);
452452
if (ret)
453-
goto err;
453+
goto err_xa_alloc;
454454
return pin;
455-
err:
455+
err_xa_alloc:
456456
xa_destroy(&pin->dpll_refs);
457457
xa_destroy(&pin->parent_refs);
458+
err_pin_prop:
458459
kfree(pin);
459460
return ERR_PTR(ret);
460461
}

0 commit comments

Comments
 (0)