Re: [PATCH] clocksource/drivers: Fix memory leak in ttc_setup_clockevent

From: Markus Elfring
Date: Tue Oct 22 2019 - 04:27:10 EST

> In the impelementation of ttc_setup_clockevent() the allocated memory
> for ttcce should be released if clk_notifier_register() fails.

* Please avoid the copying of typos from previous change descriptions.

* Under which circumstances will an âimperative moodâ matter for you here?

> +++ b/drivers/clocksource/timer-cadence-ttc.c
> @@ -424,6 +424,7 @@ static int __init ttc_setup_clockevent(struct clk *clk,
> &ttcce->ttc.clk_rate_change_nb);
> if (err) {
> pr_warn("Unable to register clock notifier.\n");
> + kfree(ttcce);
> return err;
> }

This addition looks correct.
But I would prefer to move such exception handling code to the end of
this function implementation so that duplicate source code will be reduced.