Re: [PATCH]optimize error handling in tick_check_new_device

From: Nicolai Stange
Date: Wed Jul 27 2016 - 08:23:39 EST


"Gaurav Jindal (Gaurav Jindal)" <Gaurav.Jindal@xxxxxxxxxxxxxx> writes:
> diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c
> index 4fcd99e..23faf4a 100644
> --- a/kernel/time/tick-common.c
> +++ b/kernel/time/tick-common.c
> @@ -307,6 +307,9 @@ void tick_check_new_device(struct clock_event_device *newdev)
> td = &per_cpu(tick_cpu_device, cpu);
> curdev = td->evtdev;


>
> + if (!try_module_get(newdev->owner))
> + return;
> +

Doesn't this leak a reference to newdev->owner if one of the following
conditions hold?

> /* cpu local device ? */
> if (!tick_check_percpu(curdev, newdev, cpu))
> goto out_bc;
> @@ -315,8 +318,6 @@ void tick_check_new_device(struct clock_event_device *newdev)
> if (!tick_check_preferred(curdev, newdev))
> goto out_bc;



> - if (!try_module_get(newdev->owner))
> - return;
>

Thanks,

Nicolai