]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
PM / devfreq: Unlock mutex and free devfreq struct in error path
authorLukasz Luba <lukasz.luba@arm.com>
Mon, 15 Mar 2021 09:31:23 +0000 (09:31 +0000)
committerChanwoo Choi <cw00.choi@samsung.com>
Thu, 8 Apr 2021 04:14:45 +0000 (13:14 +0900)
The devfreq->lock is held for time of setup. Release the lock in the
error path, before jumping to the end of the function.

Change the goto destination which frees the allocated memory.

Cc: v5.9+ <stable@vger.kernel.org> # v5.9+
Fixes: 4dc3bab8687f ("PM / devfreq: Add support delayed timer for polling mode")
Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
drivers/devfreq/devfreq.c

index b6d3e7db0b0979370ab009ba7f3cbe03f20bb40f..99b2eeedc2387e0af41c519e5751679f368d4842 100644 (file)
@@ -822,7 +822,8 @@ struct devfreq *devfreq_add_device(struct device *dev,
 
        if (devfreq->profile->timer < 0
                || devfreq->profile->timer >= DEVFREQ_TIMER_NUM) {
-               goto err_out;
+               mutex_unlock(&devfreq->lock);
+               goto err_dev;
        }
 
        if (!devfreq->profile->max_state && !devfreq->profile->freq_table) {