From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45D7CC43381 for ; Mon, 15 Mar 2021 10:02:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 127CE64E99 for ; Mon, 15 Mar 2021 10:02:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229579AbhCOKBp (ORCPT ); Mon, 15 Mar 2021 06:01:45 -0400 Received: from foss.arm.com ([217.140.110.172]:57098 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229494AbhCOKBS (ORCPT ); Mon, 15 Mar 2021 06:01:18 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8BE4D1FB; Mon, 15 Mar 2021 03:01:17 -0700 (PDT) Received: from [10.57.12.51] (unknown [10.57.12.51]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 71C1B3F70D; Mon, 15 Mar 2021 03:01:16 -0700 (PDT) Subject: Re: [PATCH v2] PM / devfreq: Unlock mutex and free devfreq struct in error path To: Chanwoo Choi Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, myungjoo.ham@samsung.com, kyungmin.park@samsung.com, stable@vger.kernel.org References: <20210315093123.20049-1-lukasz.luba@arm.com> From: Lukasz Luba Message-ID: Date: Mon, 15 Mar 2021 10:01:15 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/15/21 9:54 AM, Chanwoo Choi wrote: > On 3/15/21 6:31 PM, Lukasz Luba wrote: >> 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+ # v5.9+ >> Fixes: 4dc3bab8687f ("PM / devfreq: Add support delayed timer for polling mode") >> Signed-off-by: Lukasz Luba >> --- >> v2: >> - added fixes tag and CC stable v5.9+ >> - used capital letter in commit header >> >> >> drivers/devfreq/devfreq.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c >> index b6d3e7db0b09..99b2eeedc238 100644 >> --- a/drivers/devfreq/devfreq.c >> +++ b/drivers/devfreq/devfreq.c >> @@ -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) { >> > > > Applied it. Thanks. > Thank you Chanwoo! Regards, Lukasz