Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934533AbcJ0AGF (ORCPT ); Wed, 26 Oct 2016 20:06:05 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:33932 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932332AbcJ0AGD (ORCPT ); Wed, 26 Oct 2016 20:06:03 -0400 MIME-version: 1.0 Content-type: text/plain; charset=utf-8 X-AuditID: cbfee61a-f79926d000005981-cc-581144e8d20f Subject: Re: [PATCH v3] PM / devfreq: Restart previous governor if new governor fails to start To: Saravana Kannan , "Rafael J. Wysocki" , MyungJoo Ham , Kyungmin Park , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org References: <1477509425-16936-1-git-send-email-skannan@codeaurora.org> From: Chanwoo Choi Organization: Samsung Electronics Message-id: Date: Thu, 27 Oct 2016 09:06:00 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 In-reply-to: <1477509425-16936-1-git-send-email-skannan@codeaurora.org> Content-transfer-encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrJIsWRmVeSWpSXmKPExsVy+t9jQd0XLoIRBvPv6FucbXrDbnF51xw2 i8+9RxgtbjeuYLM4c/oSq8WBixPZHNg8Lvf1MnlsudrO4tG3ZRWjx+dNcgEsUW42GamJKalF Cql5yfkpmXnptkqhIW66FkoKeYm5qbZKEbq+IUFKCmWJOaVAnpEBGnBwDnAPVtK3S3DLWLiJ v6CDv2Lmly2sDYwtPF2MnBwSAiYSl29vZoSwxSQu3FvP1sXIxSEkMItRYsXBlUwgCV4BQYkf k++xdDFycDALqEtMmZILUfOAUeJL61YWkBphgQSJhrZjzCAJEYGXjBIPb3azQlTNYZR4dnEm WBWbgJbE/hc32EBsfgFFias/HjNCbLCTeLCwDWwDi4CqxKXNRiBhUYEIiVsPO8BaOQXcJZbP XQTWyiwgL3HwynOWCYxAZyLcNwvhvllIqhYwMq9ilEgtSC4oTkrPNcxLLdcrTswtLs1L10vO z93ECI6mZ1I7GA/ucj/EKMDBqMTDq/BeIEKINbGsuDL3EKMEB7OSCO9pe8EIId6UxMqq1KL8 +KLSnNTiQ4ymQOdOZJYSTc4HRnpeSbyhibmJubGBhbmlpYmRkjhv4+xn4UIC6YklqdmpqQWp RTB9TBycUg2Mu3/pPZB1WlYdH+kjNWvX4Y95yps6458en+GpfCeqiL/ImKffOoo5TipJfsmd uDlLYgNuT+Faf9HobJGZ03y2g4FRSYF8LlrJiz1tpsSILZ5VtsJRTauM5e/Eo7xB3dK+Mw7Z iD1rS74gMnW6TVe7ukyqbNWDPe8mvWP5pnuxJ0XJeOflfnUlluKMREMt5qLiRAArBQAZvAIA AA== X-MTR: 20000000000000000@CPGS Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1869 Lines: 59 Hi, On 2016년 10월 27일 04:17, Saravana Kannan wrote: > If the new governor fails to start, switch back to old governor so that the > devfreq state is not left in some weird limbo. > > Signed-off-by: Saravana Kannan > --- > * Fix NULL deref for real this time. > * Addressed some style preferences. > > drivers/devfreq/devfreq.c | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > > diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c > index bf3ea76..77c41a5 100644 > --- a/drivers/devfreq/devfreq.c > +++ b/drivers/devfreq/devfreq.c > @@ -919,7 +919,7 @@ static ssize_t governor_store(struct device *dev, struct device_attribute *attr, > struct devfreq *df = to_devfreq(dev); > int ret; > char str_governor[DEVFREQ_NAME_LEN + 1]; > - struct devfreq_governor *governor; > + const struct devfreq_governor *governor, *prev_governor; > > ret = sscanf(buf, "%" __stringify(DEVFREQ_NAME_LEN) "s", str_governor); > if (ret != 1) > @@ -944,12 +944,21 @@ static ssize_t governor_store(struct device *dev, struct device_attribute *attr, > goto out; > } > } > + prev_governor = df->governor; > df->governor = governor; > strncpy(df->governor_name, governor->name, DEVFREQ_NAME_LEN); > ret = df->governor->event_handler(df, DEVFREQ_GOV_START, NULL); > - if (ret) > + if (ret) { > dev_warn(dev, "%s: Governor %s not started(%d)\n", > __func__, df->governor->name, ret); > + if (prev_governor) { I think that prev_governor is always set. You don't need to check it. Why do check it? > + df->governor = prev_governor; > + strncpy(df->governor_name, prev_governor->name, > + DEVFREQ_NAME_LEN); > + df->governor->event_handler(df, DEVFREQ_GOV_START, > + NULL); > + } > + } > out: > mutex_unlock(&devfreq_list_lock); > > -- Best Regards, Chanwoo Choi