]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 May 2021 08:49:24 +0000 (10:49 +0200)
commit 8b50a7995770d41a2e8d9c422cd2882aca0dedd2 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/devfreq/devfreq.c

index 6aa10de792b33060cd9840c471d62c8f9e87737f..7473405b9c2380a100b0716e22be756e41d6e8fe 100644 (file)
@@ -818,7 +818,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) {