Skip to content

Commit 3614bf9

Browse files
Michal Swiatkowskidavem330
authored andcommitted
dpll: fix xa_alloc_cyclic() error handling
In case of returning 1 from xa_alloc_cyclic() (wrapping) ERR_PTR(1) will be returned, which will cause IS_ERR() to be false. Which can lead to dereference not allocated pointer (pin). Fix it by checking if err is lower than zero. This wasn't found in real usecase, only noticed. Credit to Pierre. Fixes: 97f265e ("dpll: allocate pin ids in cycle") Signed-off-by: Michal Swiatkowski <[email protected]> Reviewed-by: Vadim Fedorenko <[email protected]> Reviewed-by: Arkadiusz Kubalewski <[email protected]> Reviewed-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f3b97b7 commit 3614bf9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/dpll/dpll_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ dpll_pin_alloc(u64 clock_id, u32 pin_idx, struct module *module,
505505
xa_init_flags(&pin->parent_refs, XA_FLAGS_ALLOC);
506506
ret = xa_alloc_cyclic(&dpll_pin_xa, &pin->id, pin, xa_limit_32b,
507507
&dpll_pin_xa_id, GFP_KERNEL);
508-
if (ret)
508+
if (ret < 0)
509509
goto err_xa_alloc;
510510
return pin;
511511
err_xa_alloc:

0 commit comments

Comments
 (0)