Skip to content

Commit 63e72e5

Browse files
Dan Carpenterglaubitz
authored andcommitted
sh: intc: Fix use-after-free bug in register_intc_controller()
In the error handling for this function, d is freed without ever removing it from intc_list which would lead to a use after free. To fix this, let's only add it to the list after everything has succeeded. Fixes: 2dcec7a ("sh: intc: set_irq_wake() support") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
1 parent 3c891f7 commit 63e72e5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/sh/intc/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ int __init register_intc_controller(struct intc_desc *desc)
209209
goto err0;
210210

211211
INIT_LIST_HEAD(&d->list);
212-
list_add_tail(&d->list, &intc_list);
213212

214213
raw_spin_lock_init(&d->lock);
215214
INIT_RADIX_TREE(&d->tree, GFP_ATOMIC);
@@ -369,6 +368,7 @@ int __init register_intc_controller(struct intc_desc *desc)
369368

370369
d->skip_suspend = desc->skip_syscore_suspend;
371370

371+
list_add_tail(&d->list, &intc_list);
372372
nr_intc_controllers++;
373373

374374
return 0;

0 commit comments

Comments
 (0)