From patchwork Mon Sep 23 16:34:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonard Crestez X-Patchwork-Id: 11157327 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C924713B1 for ; Mon, 23 Sep 2019 16:34:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B053A2089F for ; Mon, 23 Sep 2019 16:34:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388084AbfIWQer (ORCPT ); Mon, 23 Sep 2019 12:34:47 -0400 Received: from inva020.nxp.com ([92.121.34.13]:40710 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387922AbfIWQer (ORCPT ); Mon, 23 Sep 2019 12:34:47 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 0B8501A0321; Mon, 23 Sep 2019 18:34:46 +0200 (CEST) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id F211E1A015C; Mon, 23 Sep 2019 18:34:45 +0200 (CEST) Received: from fsr-ub1864-112.ea.freescale.net (fsr-ub1864-112.ea.freescale.net [10.171.82.98]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id 7D03E20634; Mon, 23 Sep 2019 18:34:45 +0200 (CEST) From: Leonard Crestez To: Matthias Kaehlcke , MyungJoo Ham , Kyungmin Park Cc: Chanwoo Choi , =?utf-8?b?QXJ0dXIgxZp3aWdvxYQ=?= , Krzysztof Kozlowski , Lukasz Luba , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] PM / devfreq: Check NULL governor in available_governors_show Date: Mon, 23 Sep 2019 19:34:43 +0300 Message-Id: <96f459015e6418cee4fa20fdbdb80c4caf417c19.1569256298.git.leonard.crestez@nxp.com> X-Mailer: git-send-email 2.17.1 X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The governor is initialized after sysfs attributes become visible so in theory the governor field can be NULL here. Signed-off-by: Leonard Crestez Reviewed-by: Matthias Kaehlcke Reviewed-by: Chanwoo Choi --- 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 .