Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1494979pxf; Fri, 12 Mar 2021 10:48:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJwzwBjeuQTAbZNzPYxLxnK2EhpfG8q5FG7qriawsAtXZcU7bnpRXwoJKIlg+5xim/GwertQ X-Received: by 2002:a17:906:3552:: with SMTP id s18mr10273932eja.497.1615574926546; Fri, 12 Mar 2021 10:48:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615574926; cv=none; d=google.com; s=arc-20160816; b=LFaw118usNy5i8QhHC361qDZ8NM92Au3cAsK5DoArj9OIwzAFM8n5QOs1wiFt2poe3 uX3N7rFYWHfMlGtxcUdpU1Wi/1/TO8j0dp3KruX3Wba6+y6/xVXVQ4fcVj4+0Hgyb7UA Tth/1V6ErY9440ydvA/kNeHsSAl4DMHDSqIssQTx0Z1zMfSpgOc5b90YN7xgNB8nZ3/R 0LA40YYULPYzXYACa8Z7hZO15fH5LwZWiaCdVzuXUdo9Ymd9r/uLfWJ5ubKOaoTZsbjm 84JjBbDDWp0c68OCSLlIBkHi7zZDI3KR9QdfGjIVPKgFYY/Rs1ku6j5ZZ10RE2NwrXX6 hjZw== 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=KwbvBYjfTur/8zIwmfYv1LnriSlHrOwn8mstWmopmwM=; b=Bb1WSVzDnBEANGCNEDRJWBimHR8JIzSupMaPiN2d1/HYRMZdRFnik6N7LQ0qNcuoUY QyIZ2luTm+XqkqXAhhOUsz0EKcBJsK2aydaz/HxqNFYud67oU6lapC9UFKFHEvwPv1qC KR/9P4KKNEa6op83h3+4zad6jaP18jYmA+VWTxJJEyXcmESXvROytLxQ2djDOrjdU94y NyKaswHWADPIC4k70G9xilxxyKV5BCx1przbtziqfLEhkX2kmOw9qHAdPoMUJYrv7wM/ 27jJUlUMW4RNKWUOYbuO0OC10Gdh4osHgITm3lK44vPslxsRT7U6kafxymGYHTEAiULi QwCA== 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 bx3si4726096edb.594.2021.03.12.10.48.23; Fri, 12 Mar 2021 10:48:46 -0800 (PST) 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 S234015AbhCLSqU (ORCPT + 99 others); Fri, 12 Mar 2021 13:46:20 -0500 Received: from foss.arm.com ([217.140.110.172]:59488 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233973AbhCLSpu (ORCPT ); Fri, 12 Mar 2021 13:45:50 -0500 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 E333AED1; Fri, 12 Mar 2021 10:45:49 -0800 (PST) Received: from e123648.arm.com (unknown [10.57.17.106]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 40E8C3F7D7; Fri, 12 Mar 2021 10:45:48 -0800 (PST) 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 Subject: [PATCH] PM / devfreq: unlock mutex and free devfreq struct in error path Date: Fri, 12 Mar 2021 18:45:34 +0000 Message-Id: <20210312184534.6423-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. 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) { -- 2.17.1