Received: by 2002:ab2:7041:0:b0:1f4:bcc8:f211 with SMTP id x1csp67271lql; Fri, 12 Apr 2024 04:08:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXePb7bYbjUaEjn0ZjCSEgDjms/JJmX4IwA/eQq+gJfoqelC33WLo1yXmw2T179N4fNg8Zemiq5tEX1ESmMQjJXLB1vtJiiXfOR+Vt10g== X-Google-Smtp-Source: AGHT+IE1I8wHPJlIJqUjaSpsA37unzWByuQBxXjlrqzynzDH14zLMMSMkQJnAO6OlbABA8XJMgx/ X-Received: by 2002:a17:906:245a:b0:a51:91fb:efb1 with SMTP id a26-20020a170906245a00b00a5191fbefb1mr1388475ejb.72.1712920123400; Fri, 12 Apr 2024 04:08:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712920123; cv=pass; d=google.com; s=arc-20160816; b=fX+0w+JbHA+Was7pUvo8CMcCcTEBe5KHpQacX2psWAIpYmzlnPfO5O4Uu71p5fr1fl 4oHMIyCRVbgqzPi8ZuuQWkD5dmGMzWb8TJsDM8TX+1YL51ctSwxarw6gdlNcKyxrb6Sm pLnd3P4OG5U066A/ouv19MosxCU4PjF2aE/SnhN++15dV1pmb7Ud1GAiqJx0/3IBHMq/ 2bjx/tfyARuCFYyOvgzgj2DYPOWFbV+tZFgDo45bQzwurIpkV+FCr7oxXcDE3h5mw375 i/V3bfwlcgVHTwBOn0JZwShL4H15xpm15N4GbczdXMROdDekS41UIwo0u3X4vPCs6L88 5AKw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=euMDtgn0ibBzT3VGq58HsjF4tWklsKW6QH6dm4FXkkk=; fh=XXsVh4YcQSGtau3bbVzEvfJ4NF9CojMYt6YEQzST0zw=; b=c9uSYukTdBgyLwGscrs4L5uubCyHmZK7ZkVZvbg/T8AfABsrAYzRi6k4ppgTwsi0Te pKAH8Wz6EmC5X2YnhVKNR1ra9WswPBM/ZLHBwFEPLvJ+LvuifIidyzU/P7IQzg+mHX32 j962c4frPy1GcWIG7xM98beFU4wM3+pCxRf949HoSO0Z5is8jXq8MovNjsgEOaLpBqD8 +YMRCsKwOM08Wj21tdh8FqhtQ86ugHc///m4eiBDINpbIF/FRF0oDpYKkt5skOBUUTfX EHK5xTgpWCtbg2lMV/70CLr8SfW6pH+0+ti898K8Lktw22YsmyqgxeMKZIrI8bzHtg0M zbiA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="B2Co/ig4"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-142555-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142555-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id lv27-20020a170906bc9b00b00a51d4637d37si1592516ejb.981.2024.04.12.04.08.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 04:08:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142555-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="B2Co/ig4"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-142555-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142555-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1ED331F21B21 for ; Fri, 12 Apr 2024 11:08:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1D648537FB; Fri, 12 Apr 2024 11:08:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="B2Co/ig4" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4185742AA2; Fri, 12 Apr 2024 11:08:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712920114; cv=none; b=NhTmR0fp4jargjOGkpA/G1+9rrfAWNuSzxH9MV0Wzwt6fHzqAfgHQT1W03FaDirxl3zAhWSYcXW7F+cCcvQyVYiGuUKKHNEQCbel7VTfqHffoGq3Zlb+xSk5Dc+5pUB0PjiqlmlYlgXJuu7kawNKdD4Oa0oMhJOPtdERTF9lH6k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712920114; c=relaxed/simple; bh=aZygeNBLEEDvbPmqCRdbWqGVMAlMZFqaBfZ8Ykze24A=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=a3zCBcJlon8cM21A5THsahofqAqSwQAl8GuUrwz41nAjvxnKxPnUhTbYDdafVR5H2g3awyte/S8566OCt3C6qHFo3CDPu8OjMEO/epKMfzc6Be6UXyf9kBEfeDQp99gK/oD38eIHaLdnPWYBoIu2IHlpYW0xass7HIugfUyi/Z0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=B2Co/ig4; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1A23C113CD; Fri, 12 Apr 2024 11:08:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712920113; bh=aZygeNBLEEDvbPmqCRdbWqGVMAlMZFqaBfZ8Ykze24A=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=B2Co/ig4fQDui8awDdlQ0XScFHJIuAiFcojLdIMiUsEyOgqaSdIXxvrkz4jilWHfS djWEcQyzBCmSfpP1BTlgocWtcVKeDWfACCJ//olPguRtir6zWVNXJWnlzw6eJeEF1V JRpveal4oxI7nG+d8Tu+xv1NsSMukzalRSWPAqOLKAGMwu6j93OeZ4ByObH4RBm1xm vEd+71IgOzcUu13veNgSH59EHFTxOWA0nH8ah7plgHzgNQwgJqs8AhFbrFW8WMYEdw gFjDk1sYuL94r/NCCFIHykBbeV2Hr9wNrSEUm55UDJ9/BUZvegPIkRNi7jqK7i3OaX H+MaLimsCJCXA== Received: by mail-ot1-f46.google.com with SMTP id 46e09a7af769-6ea0a6856d7so232322a34.1; Fri, 12 Apr 2024 04:08:33 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCVDB5tcT/cNwF3vtDz6O+vGGWCHkxHD3Dm22VuLr7Syxzh8hKZZENZH8e1+V5M1sp7lJiwjhZGVXEIG6+NuEGOQjnL4RX07sg8D0B29ZqsfM7KMc5kt5B6nSx/8FPj5cMHw26NIB2M= X-Gm-Message-State: AOJu0YzMQu0xuBRMByLyZJ8x/GkS+XE8TwvZp9VxgkWw+vRrQ2HEqSMy SRvA8eaOIpb5e7gB0ON+116mEVLuoaBPxdH9z/n9YpoRWNj+kIq1eriP59+dMO3coD//mx4ESdD nZT8wpH9QQC67NSA6WLzy10NMhmk= X-Received: by 2002:a05:6870:7a6:b0:22d:fb4b:9d11 with SMTP id en38-20020a05687007a600b0022dfb4b9d11mr2454769oab.4.1712920112998; Fri, 12 Apr 2024 04:08:32 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: In-Reply-To: From: "Rafael J. Wysocki" Date: Fri, 12 Apr 2024 13:08:21 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] cpufreq: exit() callback is optional To: Viresh Kumar Cc: "Rafael J. Wysocki" , linux-pm@vger.kernel.org, Vincent Guittot , sensor1010@163.com, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Apr 12, 2024 at 7:49=E2=80=AFAM Viresh Kumar wrote: > > The exit() callback is optional and shouldn't be called without checking > a valid pointer first. > > Also, we must clear freq_table pointer even if the exit() callback isn't > present. > > Signed-off-by: Viresh Kumar > --- > drivers/cpufreq/cpufreq.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index 66e10a19d76a..fd9c3ed21f49 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -1679,10 +1679,13 @@ static void __cpufreq_offline(unsigned int cpu, s= truct cpufreq_policy *policy) > */ > if (cpufreq_driver->offline) { > cpufreq_driver->offline(policy); > - } else if (cpufreq_driver->exit) { > - cpufreq_driver->exit(policy); > - policy->freq_table =3D NULL; > + return; > } > + > + if (cpufreq_driver->exit) > + cpufreq_driver->exit(policy); > + > + policy->freq_table =3D NULL; > } > > static int cpufreq_offline(unsigned int cpu) > @@ -1740,7 +1743,7 @@ static void cpufreq_remove_dev(struct device *dev, = struct subsys_interface *sif) > } > > /* We did light-weight exit earlier, do full tear down now */ > - if (cpufreq_driver->offline) > + if (cpufreq_driver->offline && cpufreq_driver->exit) > cpufreq_driver->exit(policy); > > up_write(&policy->rwsem); > -- I have applied this patch (for 6.10 because I don't think it is urgent) because it addresses both issues with missing ->exit() driver callback checks. I honestly don't think it would be better to apply a separate patch for each of them. Thanks!