From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from imap1.codethink.co.uk ([176.9.8.82]:34403 "EHLO imap1.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751028AbeDAU4p (ORCPT ); Sun, 1 Apr 2018 16:56:45 -0400 Message-ID: <1522616201.2654.79.camel@codethink.co.uk> Subject: Re: [PATCH 4.4 092/134] cpufreq: Fix governor module removal race From: Ben Hutchings To: Greg Kroah-Hartman , linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org, "Rafael J. Wysocki" , Viresh Kumar , Sasha Levin Date: Sun, 01 Apr 2018 21:56:41 +0100 In-Reply-To: <20180319171902.578082436@linuxfoundation.org> References: <20180319171849.024066323@linuxfoundation.org> <20180319171902.578082436@linuxfoundation.org> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org List-ID: On Mon, 2018-03-19 at 19:06 +0100, Greg Kroah-Hartman wrote: > 4.4-stable review patch.  If anyone has any objections, please let me know. > > ------------------ > > From: "Rafael J. Wysocki" > > > [ Upstream commit a8b149d32b663c1a4105273295184b78f53d33cf ] [...] > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -551,6 +551,8 @@ static int cpufreq_parse_governor(char * >   *governor = t; >   err = 0; >   } > + if (t && !try_module_get(t->owner)) > + t = NULL; This won't work because t is dead after this point.  The fix appears to depend on: commit 045149e6a22119e5bf0d16a0b24a4173a2abb71d Author: Rafael J. Wysocki Date: Thu Nov 23 01:23:16 2017 +0100 cpufreq: Clean up cpufreq_parse_governor() which moves the assignment to *governor further down. Ben.   >   mutex_unlock(&cpufreq_governor_mutex); >   } > @@ -669,6 +671,10 @@ static ssize_t store_scaling_governor(st >   return -EINVAL; >   >   ret = cpufreq_set_policy(policy, &new_policy); > + > + if (new_policy.governor) > + module_put(new_policy.governor->owner); > + >   return ret ? ret : count; >  } >   -- Ben Hutchings Software Developer, Codethink Ltd.