Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4325ybl; Tue, 7 Jan 2020 13:00:14 -0800 (PST) X-Google-Smtp-Source: APXvYqxqqUtzMBaIJHpu8xgPTQehgRc5jL63u5fDOWI15HH3hn4KahUjcco3YFC2O3TkeNMuOKQt X-Received: by 2002:aca:43c1:: with SMTP id q184mr296454oia.116.1578430814683; Tue, 07 Jan 2020 13:00:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578430814; cv=none; d=google.com; s=arc-20160816; b=rNqNRFAJZKZEig6PPUDWQ0BWeDNuAs10AqmtTy4WevKr0poRuHvCFS/4mRtWwUM1nl 9aWER+SWMTY0tS1LlkHlIt/QwUSBU+C8yjeD3Mb9z7N4dHhnY/359Mh8dUN6yYAe6ADP eK0XFBXtVnCkuDHtYh17XewOO7Dw0NrA7LcP4dmqAFVywTfngS5K1SorVLm6TYAntnh5 wok2cIEJSOzceYkpYSHomnKqz6XbPCIrz7inYeCNq2LC3w3k+2KNhKZvmzFlxAqRduhl VT05JsV3jbLJUNCXdwxR0mCm1t2XAJfBrEop+Ldqk80Z6nIrfThELFItqWBwdY0nWgxl wGdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lDvd0PZhRg3sjYr/klb520fWMmEGapJa8EanAGRbMog=; b=wtN0RZlnW4S2bZWSOaxTHfQz73aAgfLAhtSBX7P1z502f/fFCfRJsYT/NdUBopvzB7 7cuQO0Yn5pkuOKoPIOjiApg5wa4GyyG3uElj95vucbeAJCdj/vrDAxnJ/OIS4NfmS7pb LQWY49VZ4dqFAGQjyrPpxMarqKsKJ2b6+f4LqM/DYLqAPae+MYul/w0XdmDF/r33SfSF pkBHLjWJTm0bMzT/9ZEtUzVuHPGNXcXo8nAHeewYFDHLjZ5Xm53gPoR9/GEMun+Cl21I iuKLpB12lnHEe9AR0tzL8DROUbmwqKUdrUCCRI0vptRQxa8fiQPl/nutg2B4OaP1pvXl gtJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KzSbmmX3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j9si472489otq.317.2020.01.07.13.00.01; Tue, 07 Jan 2020 13:00:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@kernel.org header.s=default header.b=KzSbmmX3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727709AbgAGU5t (ORCPT + 99 others); Tue, 7 Jan 2020 15:57:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:55602 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727686AbgAGU5r (ORCPT ); Tue, 7 Jan 2020 15:57:47 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 85341208C4; Tue, 7 Jan 2020 20:57:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578430667; bh=CTLj3I7GCavrJ2mj3GL9XFuisCY/3DPY4JOT+OXwrq0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KzSbmmX3r2A+bvxmVWzA/Rm9ircP+UsN+yx6lYap200U26TOHof0cuKj+5D3Z1SWE oP4d0Kqg5D0O+4Ic+CVAjtuIbGBAQMJft+THV+KCWXksBAN2sJPXwqVkypFDoUl31x i4VFs9zf6omIh+9a2/x9tSis7AITXRYXLn5odx9I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Leonard Crestez , Matthias Kaehlcke , Chanwoo Choi , Sasha Levin Subject: [PATCH 5.4 018/191] PM / devfreq: Dont fail devfreq_dev_release if not in list Date: Tue, 7 Jan 2020 21:52:18 +0100 Message-Id: <20200107205333.980001860@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200107205332.984228665@linuxfoundation.org> References: <20200107205332.984228665@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Leonard Crestez [ Upstream commit 42a6b25e67df6ee6675e8d1eaf18065bd73328ba ] Right now devfreq_dev_release will print a warning and abort the rest of the cleanup if the devfreq instance is not part of the global devfreq_list. But this is a valid scenario, for example it can happen if the governor can't be found or on any other init error that happens after device_register. Initialize devfreq->node to an empty list head in devfreq_add_device so that list_del becomes a safe noop inside devfreq_dev_release and we can continue the rest of the cleanup. Signed-off-by: Leonard Crestez Reviewed-by: Matthias Kaehlcke Reviewed-by: Chanwoo Choi Signed-off-by: Chanwoo Choi Signed-off-by: Sasha Levin --- drivers/devfreq/devfreq.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index e185c8846916..ffd2d6b44dfb 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -588,11 +588,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); @@ -647,6 +642,7 @@ struct devfreq *devfreq_add_device(struct device *dev, devfreq->dev.parent = dev; devfreq->dev.class = devfreq_class; devfreq->dev.release = devfreq_dev_release; + INIT_LIST_HEAD(&devfreq->node); devfreq->profile = profile; strncpy(devfreq->governor_name, governor_name, DEVFREQ_NAME_LEN); devfreq->previous_freq = profile->initial_freq; -- 2.20.1