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 A5BA0C43603 for ; Fri, 20 Dec 2019 14:36:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 761AF2467F for ; Fri, 20 Dec 2019 14:36:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576852615; bh=gnJZRlgJ/CeVAJBsrZW+w07CQEeA1dGWRqEb9Mh6Uuo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=g1jCpXt4T3kLVPX5xpPBDcVmHmnptmJ+XD7AmTYjncxadO7n8V7cR9zaa+kLRwDKg tLzLHTAMiZ2d04BkqW2DN/ztpJ8iBg+zrKPpoKdE5TvvT8zkSoMjDQGv6uR1X3SKvP cAYMb6qoqIgB+8YT6yhZ+Uap1Q219U5Nz89joOaE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728175AbfLTOgy (ORCPT ); Fri, 20 Dec 2019 09:36:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:38892 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728280AbfLTOeq (ORCPT ); Fri, 20 Dec 2019 09:34: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 C53582468A; Fri, 20 Dec 2019 14:34:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576852485; bh=gnJZRlgJ/CeVAJBsrZW+w07CQEeA1dGWRqEb9Mh6Uuo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TJG4we+09fASlW5b05g9fnQIBQkLn4A/6Njvrw3hWfOTGBWFM74MuRfULiH0zTWNg S14cyW9R8V0WEnh2/YxBsCRPUTyMzSLad7OewN4Tt/tY25d0JFPqGk3uwcgM1vW9hY NvTlytzM+mkQE6lLsvibKgRN4QnUM0/tTcG5ceaA= 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.19 09/34] PM / devfreq: Don't fail devfreq_dev_release if not in list Date: Fri, 20 Dec 2019 09:34:08 -0500 Message-Id: <20191220143433.9922-9-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191220143433.9922-1-sashal@kernel.org> References: <20191220143433.9922-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 a47e76a62287f..69bbb1e9ab23d 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -575,11 +575,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); @@ -634,6 +629,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