From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE133C43603 for ; Fri, 20 Dec 2019 14:47:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BBDB021D7E for ; Fri, 20 Dec 2019 14:47:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576853268; bh=MO0/HY9PnNyk0zObAy/yukYooxhFZmu/FbobxKc5itY=; h=From:To:Cc:Subject:Date:List-ID:From; b=IArvfzXpGfRarXMXGBd1PZ8fswCR1wuquTpM7FOQJkyQ0mHU0DJBCA+vt+IWdlyhT fyiuS1emZQmY1HqESZrgldVqgQk8ryib0GCeFa+8DOWr8Joyv3IAlKRZP9QdUI+mW3 hWgnfFiQPf2Yg8TjzvvAFyp+emngc5YW6QqtZ9LE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727390AbfLTOrr (ORCPT ); Fri, 20 Dec 2019 09:47:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:46136 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727381AbfLTOrq (ORCPT ); Fri, 20 Dec 2019 09:47:46 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 355E021D7E; Fri, 20 Dec 2019 14:47:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576853266; bh=MO0/HY9PnNyk0zObAy/yukYooxhFZmu/FbobxKc5itY=; h=From:To:Cc:Subject:Date:From; b=ULsynnl43c3Cjf7487bCQ6bgVR+orGb7F5JtLAy1zBjqGL729pDxvTq8YZmSC6etB JtreBs3f+WmfisFbtDHKGMLvVjA035YpGL6pqZ+7+5KJmuA02spqhxpQrE6nvfpvCR qTvxoDAeire7yycyobKYLsr/p/SflhOmrdytvcAQ= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Leonard Crestez , Matthias Kaehlcke , Chanwoo Choi , Sasha Levin , linux-pm@vger.kernel.org Subject: [PATCH AUTOSEL 4.4 01/11] PM / devfreq: Don't fail devfreq_dev_release if not in list Date: Fri, 20 Dec 2019 09:47:33 -0500 Message-Id: <20191220144744.10565-1-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 4f6fc1cfd7da2..f01f7434df8eb 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -396,11 +396,6 @@ static int devfreq_notifier_call(struct notifier_block *nb, unsigned long type, static void _remove_devfreq(struct devfreq *devfreq) { 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); @@ -472,6 +467,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