Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3144172pxf; Mon, 15 Mar 2021 02:33:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNN8d4Z/e70SijkKeIB4RVVB3Bcnsf79dYnlpsAAyOZdAVabSjaDokPIy/HYJJQzt0vIH+ X-Received: by 2002:a17:906:3881:: with SMTP id q1mr22651393ejd.490.1615800816692; Mon, 15 Mar 2021 02:33:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615800816; cv=none; d=google.com; s=arc-20160816; b=ssmNLRi+jZG/HFRrTwlWnjK62nUud3z5/XoO9SYTDvv1H/XOcO5uSx7U82+t6K//df ZXaMm1wFuvmiD7pI/8+pzMiGIlcAq7f6JiaQfWsV/Bt3px7s6IJmZX34NKyYdljYYIFs /ILBV7DZPnM/e2jIFjmKHYuYbcQd6lQSi6j5wrXHIvW+7kD/4bhGVvURUB27m5Wv2lIv yxd2E6CmpZSayRdvo4aCc9vCqTpn1s5d5YMddNxVhJnpWix9Dfq3AtF+oodew60r8Edj K+7qKpRWK4A+jhiEAFh7E4KSN6FqwJDPugHXgBFt3HNFuVlI/UeVVAOwG3NlKr6vTK2l ELsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=hMXF1wxEg+and6ILJ1CiQKK8/J42fmYIjpQkxckK1rI=; b=h+xBH7ispDuv9/IExGKfOBnn8Uz8ouEce2jvrRfmoIPn49M2RYCygAWuSHq+OyShcV xz9cHl3MDPVXJcjPv5H4UnjCmqgdGiEEnEe3r3zPrQKVrYzPMV26vATHwqA2PWvFSpjN H807UknN4lg3sd5WLLqjxf2KlVcigfM7z+7FGdXTbzaBntDTrEFolpPgjGqc8ronPKFd Xmb3omE42nNTGxuCOF40NZM1NycZEDX0Qh3k5akW5bEIOKhAp7+syGwaV8LKSeOjYuV4 pofQ5e0Jd20QhTtiD/FrgAO7TheDVG+d8G2bpcGgi+PXUYqo4CDFajvHYaq5PB6RGpEi MCiQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ot6si10948260ejb.337.2021.03.15.02.33.14; Mon, 15 Mar 2021 02:33:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229672AbhCOJbs (ORCPT + 99 others); Mon, 15 Mar 2021 05:31:48 -0400 Received: from foss.arm.com ([217.140.110.172]:55508 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229704AbhCOJbh (ORCPT ); Mon, 15 Mar 2021 05:31:37 -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 68DCB1FB; Mon, 15 Mar 2021 02:31:37 -0700 (PDT) Received: from e123648.arm.com (unknown [10.57.12.51]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8F5E33F70D; Mon, 15 Mar 2021 02:31:35 -0700 (PDT) From: Lukasz Luba To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, cw00.choi@samsung.com Cc: lukasz.luba@arm.com, myungjoo.ham@samsung.com, kyungmin.park@samsung.com, stable@vger.kernel.org Subject: [PATCH v2] PM / devfreq: Unlock mutex and free devfreq struct in error path Date: Mon, 15 Mar 2021 09:31:23 +0000 Message-Id: <20210315093123.20049-1-lukasz.luba@arm.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) { -- 2.17.1