From patchwork Tue Apr 24 22:35:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 134199 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp120083lji; Tue, 24 Apr 2018 15:35:42 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+w44h4bwgR3LzA0ptIfqqmpDaeKxijMAX8xXs6Rs/qQFKoMU5aczt3QpidT+jx3+AUPczV X-Received: by 10.98.0.194 with SMTP id 185mr21795006pfa.238.1524609342380; Tue, 24 Apr 2018 15:35:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524609342; cv=none; d=google.com; s=arc-20160816; b=eY27tH8wRwzN8P20R4WcVuwOWWoVtmTd9+/TWl3Tq8kklyrcGAdrkRK1xJWmOEY7Wc 48a3h+KMfFspMCIHBYcCZYk9MkyVj9UWITjIP1UwH8Pwus9ztJxaqXRNYdrOdMvh9mZY KGNLxdoRPl/umL4GfEyjrjqGoPe+aQiL5CYgs3/PNGFMcLu9VXdeK8Y4sk2F6aBVV0dE Sahq4SyH9WnnuHUsL7NVy1FOHEhdi6382fS7wbOxdzha9NppOKAYnXKda1G0n4BdLU/r G8tpKGKFPN8Xpn0CBrz6TIvtf9B8ZpojDrG+mjkR4/jmz1vYeeTMCAAzX0TCCngySeZ9 CZ/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Iw/e9HslE9jUTacks1ilgfzwYVGUzkpbC8Ek7NEQYsc=; b=FfWKXC3g3wUF421GMcFDB+sk3iAe1RHAnNuQYSrMM/gKCwyMSp3CJLzO4DjuNoxMg7 +nWcHkLn3pt4+4rnLgWP+5nDSWzQx9JCOIjLY0ajYDJwb0j91JAfnNy9Aduj7zWChKJs m6vOhLF+t98kX1F8SCvP4dhT6JdRPWrABzO9Kbo5x2KY56hijrL4Kryw31yT1u3SVYr7 vZ9SkAiNqMvZ2abY4wmDNLPlyWGEwmHio7ZlGIrWAQIvNvQMJ+6aG7aFDVZFt0U2hObD qRP6LVwmbYnxL1T5F54BOywNRNaCMOoOHRAZVnqUhsxjf14t10+1jTfQXughMpr/sox0 X02w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MAnBBLg1; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c7si12317959pgn.152.2018.04.24.15.35.41; Tue, 24 Apr 2018 15:35:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MAnBBLg1; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750779AbeDXWfh (ORCPT + 11 others); Tue, 24 Apr 2018 18:35:37 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:38405 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751245AbeDXWfa (ORCPT ); Tue, 24 Apr 2018 18:35:30 -0400 Received: by mail-pf0-f193.google.com with SMTP id o76so8746390pfi.5 for ; Tue, 24 Apr 2018 15:35:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Iw/e9HslE9jUTacks1ilgfzwYVGUzkpbC8Ek7NEQYsc=; b=MAnBBLg1wEtC8DIL0y6G4A1aQDzi9IBhgC047BPZTIPaRuDnQtXcdTUmCYJmRaQ/B8 TBzjwKnCi5+hKZKIX9tQoemjCTb6w24Zpt8w1x6fxrS1xuZoghrPe29P7K9DE+DSSfqw 5/vMQ+2kR2SqFF0DAFTv06bZ8wob5qETllrB4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Iw/e9HslE9jUTacks1ilgfzwYVGUzkpbC8Ek7NEQYsc=; b=hP4B3fP9ecjypvWMsXpjaKYsKuIY+Q3g2Dn43K0go/L9tRZBxTBvBU1AvhcW6CfzxK 3Iv2/BE+ebf+0vWNko5LQd6zI/n29d0wy3kA6tOKcNpZcFIIaXFtNWeBiTIn33YudBfP kUh75ZKtDA7RCcXWTYGPlyrrcA0Qqs/B0pVWMTkeR+ygHU8Tstj7AhMDWBoCxDdcpUC7 69vVqfws1ulgOuXe6oN6fyuITwF8yn//u9GOkis1hZ7CE6olaX2YyKn1qEbkwn/Yjp+9 58wnOpv2iKCu1EH4CIeix1rcxE0xMZ5aPozenuw1vGJuhNns6HAuw84jF+aKe4TIDYD1 Xllw== X-Gm-Message-State: ALQs6tAhd5J/LNOfh740uQI/Kx27kLTPC65TVgykS7Ea2YdvMH3XEZcg DW0bG5ocFht1KD7cggAcu93RabBNlBY= X-Received: by 10.101.97.72 with SMTP id o8mr21990478pgv.120.1524609330167; Tue, 24 Apr 2018 15:35:30 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id w26sm35856621pfi.17.2018.04.24.15.35.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 15:35:29 -0700 (PDT) From: Bjorn Andersson To: MyungJoo Ham , Kyungmin Park , Chanwoo Choi Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/6] PM / devfreq: Use put_device() on device_register error Date: Tue, 24 Apr 2018 15:35:20 -0700 Message-Id: <20180424223521.28193-6-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180424223521.28193-1-bjorn.andersson@linaro.org> References: <20180424223521.28193-1-bjorn.andersson@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org After calling device_register() the dev must be released using put_device() rather than just freeing the carrying object. The release function of the devfreq device will be called in this case, but as we're yet to add the devfreq instance to the devfreq_list the release function would print a warning and return. But as the error path of devfreq_add_device() has been cleaned up the release function is now the only function taking the devfreq off the list, so we do not need to safe guard against the devfreq not being on the list. Signed-off-by: Bjorn Andersson --- drivers/devfreq/devfreq.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) -- 2.16.2 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 70588dc2032c..c804bd72a644 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -523,11 +523,6 @@ static void devfreq_dev_release(struct device *dev) struct devfreq *devfreq = to_devfreq(dev); mutex_lock(&devfreq_list_lock); - if (IS_ERR(find_device_devfreq(devfreq->dev.parent))) { - mutex_unlock(&devfreq_list_lock); - dev_warn(&devfreq->dev, "releasing devfreq which doesn't exist\n"); - return; - } list_del(&devfreq->node); mutex_unlock(&devfreq_list_lock); @@ -583,6 +578,7 @@ struct devfreq *devfreq_add_device(struct device *dev, goto err_out; } + INIT_LIST_HEAD(&devfreq->node); mutex_init(&devfreq->lock); devfreq->dev.parent = dev; devfreq->dev.class = devfreq_class; @@ -630,7 +626,8 @@ struct devfreq *devfreq_add_device(struct device *dev, atomic_inc_return(&devfreq_no)); err = device_register(&devfreq->dev); if (err) { - goto err_dev; + put_device(&devfreq->dev); + goto err_out; } mutex_lock(&devfreq_list_lock);