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=ham 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 008F8C433DB for ; Mon, 15 Mar 2021 09:23:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B989464E33 for ; Mon, 15 Mar 2021 09:23:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229632AbhCOJWl (ORCPT ); Mon, 15 Mar 2021 05:22:41 -0400 Received: from foss.arm.com ([217.140.110.172]:54998 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229490AbhCOJWK (ORCPT ); Mon, 15 Mar 2021 05:22:10 -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 AFBBA1FB; Mon, 15 Mar 2021 02:22:09 -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 72EFB3F70D; Mon, 15 Mar 2021 02:22:08 -0700 (PDT) Subject: Re: [PATCH] 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 References: <20210312184534.6423-1-lukasz.luba@arm.com> From: Lukasz Luba Message-ID: Date: Mon, 15 Mar 2021 09:22:07 +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 Hi Chanwoo, On 3/15/21 7:20 AM, Chanwoo Choi wrote: > Hi Lukasz, > > On 3/13/21 3:45 AM, 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. >> >> Signed-off-by: Lukasz Luba >> --- >> 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) { >> > > Looks good to me. But, need to add the following information > and please use capital letter of the first character of patch title. Thanks. thanks for looking at this, sure, I'll use the capital letter. > > Fixes: 4dc3bab8687f ("PM / devfreq: Add support delayed timer for polling mode") > > Also, need to send it to stable lkml. > I'll add the 'Fixes' tag and send v2 also into stable v5.8+: Cc: v5.8+ # v5.8+ Regards, Lukasz