From patchwork Tue Apr 24 22:35:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 134202 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp121077lji; Tue, 24 Apr 2018 15:36:54 -0700 (PDT) X-Google-Smtp-Source: AIpwx49Jt3d95g41iO61SCgp9SbzmyiO3LrnBtTJClNhRR4OCBY2gbKSfAM36miEQUjRsF2dTfBz X-Received: by 10.99.181.89 with SMTP id u25mr20962416pgo.302.1524609414307; Tue, 24 Apr 2018 15:36:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524609414; cv=none; d=google.com; s=arc-20160816; b=RC9lbV+IrrJ+ZTt5J6R0FJ1RWp5isyVlSAYYYp4Q0uTt3GaUyWQxhvqHS5txI7IGH5 hC0A6S5zoWtJOUn++PiKjwkNQbFqw2mnKeHZ5gPpL5efH9+TKp3uBl5f+AyQjRxAT2vQ suTghUfR7SelddEzKy2LcYZDjB4hk/Ea81ceBAF9fQCHqoMHeyUyCBNzjk7XcUAuyDHy S2aXFj37bE99sOXWmNHKTWEuGpHBab80Njk4S/CEPTNBaY/5ntE4tuqYnpaeo7IDgf72 poJFlTrwq1wJZSmpHNhruOkr9NpTt+l+2dUiK6QRZ7qyp3vvLijVOHliPSWiH6xY3oEJ WJtg== 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=sEw6fnSpIZzDYqn7LEpmqBuXp0kHLCC6bdGkB0q0NKg=; b=Kk6lQWb8ug6rKM3JD/7OTbhZgC1CaB4DLv5ZB5g6If0PKAwhnzaDoSJzTU8LYgIzB6 WDDH+ujkw7UwL4xo3+b/Y2/d9ojsoNtiRNIdUVxOgAaOWL0QOi/kommEfZX7l6zqO1hV 4VMsqnJ1eOmxHkijfW/WlGaPsxQTHvlZ+We0UQgJ583MFplZ8DbM479NogfBPfn+T06X y703ewwf06qQ6JZf8hCEexaE2uBR5GrrQFs8WyP4kSxfIQ6gxrpaTTkyMsj1hr53QoUg g2cvahcbKwnaeO/QVRAjkfM3nSqXE21dzcwJ54Iif8eZfmc0TIbRTLSiWlTmrhizRBnX 9d1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A6YLZ91t; 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 z5si13793862pfh.110.2018.04.24.15.36.54; Tue, 24 Apr 2018 15:36:54 -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=A6YLZ91t; 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 S1751247AbeDXWgw (ORCPT + 11 others); Tue, 24 Apr 2018 18:36:52 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:34122 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751184AbeDXWf1 (ORCPT ); Tue, 24 Apr 2018 18:35:27 -0400 Received: by mail-pf0-f196.google.com with SMTP id a14so2946986pfi.1 for ; Tue, 24 Apr 2018 15:35:27 -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=sEw6fnSpIZzDYqn7LEpmqBuXp0kHLCC6bdGkB0q0NKg=; b=A6YLZ91tXeRQoKnwKwZFLcQXgI1oSSwcyK/Ufi1LKZQT/WCHvNAYf5EfCovvl+d+v9 66cqQfGuGZKHJ5gIGz4t/ZlzIAsBgPtTCAenDeWqjgtMgukBOR15gWoO/jirCWZldY5R ovHDLP0hNAHWo+Gu1Pl4oFf/8OuZrIJ2938S0= 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=sEw6fnSpIZzDYqn7LEpmqBuXp0kHLCC6bdGkB0q0NKg=; b=KCUSTvHHiKmhUx0mtXyXk2nEQ1OOQ1Zn589Fyo/l4q9dy9qrlpR+XjC2N08RngcDlp zhjwRoc/eVRSg+IPp6vUgg02BmHt0A8EFPopsI8e6TGmd7WKlvaYvLmPl/5jHPqV/iot FpvoUSFSdLzTTGBYNuk/Z2AIJnr6qGloIJVR1+7ngjlflyIlhnf6hzdY0MFdF6eYihuM 82PuHQVWP6a+8VW7uhr/GZzTYBPeMHnNxcqFTIfKkJ6SIfP+b5iJCKCE93BxSbZ2bYR0 uYraifX4JKNQ6uExfmnM7kxO1/05WOOuE+/rQ410IU/1mToALnUZhm8ZYkHQsI6rOrU7 d0Ug== X-Gm-Message-State: ALQs6tBt4oThPiVgUYhqMOwzi3+ztKrTCUoVDwga7n8h4+bNQ1XIcEvu cBEbMD81JxqGjThI/U8VkyfeXA== X-Received: by 10.98.100.11 with SMTP id y11mr22216411pfb.118.1524609326918; Tue, 24 Apr 2018 15:35:26 -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.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 15:35:26 -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 2/6] PM / devfreq: Use the device release function for cleanup Date: Tue, 24 Apr 2018 15:35:17 -0700 Message-Id: <20180424223521.28193-3-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 Removing the devfreq from the devfreq_list before calling unregister causes the device's release function to not find the devfreq and as such bails from the release function, resulting in the following log entries if an invalid governor is specified. ufshcd-qcom 624000.ufshc: devfreq_add_device: Unable to find governor for the device devfreq devfreq0: releasing devfreq which doesn't exist Drop the removal of devfreq from the list. As the release function will end by freeing the devfreq context we have to skip the freeing of this in our error handler, and hence need to pull in the device_unregister() calls. Signed-off-by: Bjorn Andersson --- drivers/devfreq/devfreq.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) -- 2.16.2 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 30a672397ff0..d5b278b8f20e 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -647,8 +647,10 @@ struct devfreq *devfreq_add_device(struct device *dev, if (IS_ERR(governor)) { dev_err(dev, "%s: Unable to find governor for the device\n", __func__); + mutex_unlock(&devfreq_list_lock); + device_unregister(&devfreq->dev); err = PTR_ERR(governor); - goto err_init; + goto err_out; } devfreq->governor = governor; @@ -657,17 +659,14 @@ struct devfreq *devfreq_add_device(struct device *dev, if (err) { dev_err(dev, "%s: Unable to start governor for the device\n", __func__); - goto err_init; + mutex_unlock(&devfreq_list_lock); + device_unregister(&devfreq->dev); + goto err_out; } mutex_unlock(&devfreq_list_lock); return devfreq; -err_init: - list_del(&devfreq->node); - mutex_unlock(&devfreq_list_lock); - - device_unregister(&devfreq->dev); err_dev: mutex_destroy(&devfreq->lock); kfree(devfreq);