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=-8.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 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 13189C4CECF for ; Mon, 23 Sep 2019 18:50:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DA9DE20B7C for ; Mon, 23 Sep 2019 18:50:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="PC+bmEye" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727735AbfIWSuv (ORCPT ); Mon, 23 Sep 2019 14:50:51 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:34179 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726994AbfIWSuu (ORCPT ); Mon, 23 Sep 2019 14:50:50 -0400 Received: by mail-pg1-f196.google.com with SMTP id y35so2704479pgl.1 for ; Mon, 23 Sep 2019 11:50:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=OFEreeiuCWUIubUDu2nto0CXXCx0l8DJdtGf7sQk5hI=; b=PC+bmEyewuG+cCx1WrX3c9poig072MLtq/y1UcRcWcBXMSKhoY0i5IiADx21Q9ZQiI ucpQftg/fj56BCAHbQjurIeU5lwudfMoc8oN+4M4HGsrMOUnW/vcJcu+rOTvaI6E/Xce YLmVdHUNPoxYwHaMxhb/IQGLNj2dQkNbhBkjg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=OFEreeiuCWUIubUDu2nto0CXXCx0l8DJdtGf7sQk5hI=; b=APnCwJjaTNfWVue6/o5bn59pR6BKxngH9lANCDzbctolZfHxjrk4nAdKHW2i49HNuz YuaKtbxYNooiTPtmptJhgz4X1yNXC42g+nbZfzGcAqxUuwu7gD50WkDRY/CiJB9huTeN LoS5NAcpw5+Cslvca5VfBzfrRPBDjgBshVP21zym0CxnLZXOjtmAFZF+F2bDw8DHTMun pyEShhC+vo2VyMmpMvAxkY4gVuqyDHhHv5REgwesGkQ9fgmdrNf0zwEWHyHICTcZznlp lFIo2X6sdtY9PfGRTJlwdmn/N9MQwRd4ug4drKxGyQKsOi4Rud3Q6wfIzT/3qhxMdJDk hZvg== X-Gm-Message-State: APjAAAWAkBjTaLrMTsKNboWYEHiTUhpBzaYCzsD6IAd53xiJsYkxCU5c jCgIH16cljHA2N6dBO9jKNVtJQ== X-Google-Smtp-Source: APXvYqwtX/NH+k4fVe4nAuqpRJwbGGrTrWKGRhBCpwxl3cOXJkcFUpjjDRPZQlN/cssPs2EU87T9hw== X-Received: by 2002:a17:90a:8001:: with SMTP id b1mr1024129pjn.10.1569264650065; Mon, 23 Sep 2019 11:50:50 -0700 (PDT) Received: from localhost ([2620:15c:202:1:75a:3f6e:21d:9374]) by smtp.gmail.com with ESMTPSA id h6sm17603497pfg.123.2019.09.23.11.50.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 23 Sep 2019 11:50:49 -0700 (PDT) Date: Mon, 23 Sep 2019 11:50:47 -0700 From: Matthias Kaehlcke To: Leonard Crestez Cc: MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Artur =?utf-8?B?xZp3aWdvxYQ=?= , Krzysztof Kozlowski , Lukasz Luba , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] PM / devfreq: Check NULL governor in available_governors_show Message-ID: <20190923185047.GC133864@google.com> References: <96f459015e6418cee4fa20fdbdb80c4caf417c19.1569256298.git.leonard.crestez@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <96f459015e6418cee4fa20fdbdb80c4caf417c19.1569256298.git.leonard.crestez@nxp.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org On Mon, Sep 23, 2019 at 07:34:43PM +0300, Leonard Crestez wrote: > The governor is initialized after sysfs attributes become visible so in > theory the governor field can be NULL here. > > Signed-off-by: Leonard Crestez > --- > drivers/devfreq/devfreq.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > Found this by hacking device core to call attribute "show" functions > from inside device_add. > > diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c > index 00fc23fea5b2..896fb2312f2f 100644 > --- a/drivers/devfreq/devfreq.c > +++ b/drivers/devfreq/devfreq.c > @@ -1322,11 +1322,11 @@ static ssize_t available_governors_show(struct device *d, > > /* > * The devfreq with immutable governor (e.g., passive) shows > * only own governor. > */ > - if (df->governor->immutable) { > + if (df->governor && df->governor->immutable) { > count = scnprintf(&buf[count], DEVFREQ_NAME_LEN, > "%s ", df->governor_name); > /* > * The devfreq device shows the registered governor except for > * immutable governors such as passive governor . Reviewed-by: Matthias Kaehlcke