Received: by 10.213.65.68 with SMTP id h4csp44931imn; Mon, 19 Mar 2018 19:01:49 -0700 (PDT) X-Google-Smtp-Source: AG47ELsFT6FerLvpWD8SFAPTNBzgRNm81R2TWvLQNF4ffWg9Exe8qpFfHdU7bHiXzURdQphULj19 X-Received: by 2002:a17:902:b608:: with SMTP id b8-v6mr14775590pls.392.1521511309809; Mon, 19 Mar 2018 19:01:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521511309; cv=none; d=google.com; s=arc-20160816; b=UJiHKbojtHf9+Y3vaw01ulHvWWhYVr+W7nAwY+T8lJYm3k7IPsc/kcy7K3s6vrjRmj ugwG/y5oJS9XUmR2ERmP4sFpD6vV4yrMUqNqCSx32yrfOawg0e9Kqwk8KtU2RvLnL0n/ k6Eu8SaTAV1hp0X7SWqw/MVi5BDPdrSgterrZhOrW8nirBhMMY7U+itUz88cxK9/6uGp wn266tTVZXAlXkprfUUDllbQiT4ZQvbp2hYkBoS5q6PelKGhx4cTdetVTose7ulU6JsA /4LhtK4TgvGH03OmyMduxnEwEzJcCX7TqHGlwd00Zjou/eJquJbJ7hI4E0FVuc9GHziV ySpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=jKRPTK9J/fiTzn2zmGh2sk/J4pJpAFWG01gQvpZ3LkE=; b=pL/65vbGQvl1lo678R+5qyJbXhgOA4TQdl/ti8kGklebXnze9LEXbd1BmsmkPO8zeI KnyB6qxCwsikxQ9wVgIFcnuzDZZJ9gzZyu7HH1U1Bs/iQPGiB9LtvhKAJGjdjo9YfsLX hsVhY2BWpiGy9lbZ9fWccg4o3PblhcPmvu398zEs15i/6nguNBCq9et6QVFV8Rz0E5L5 Rn2Dobs3Q0o2BjrxGlTWFdDDoyR5V+X+ezEYoSSuuBePfKyee2BsfSK0LfYFLeLEaQvo inHk71koQQ2Ch69U5m++Q/JwSwQQTysy2F3FVzxNXRF9XTCPtGrvVagso5ddwSCYyJ/v Saog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=YOQWOUAi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a8-v6si575761plz.320.2018.03.19.19.01.35; Mon, 19 Mar 2018 19:01:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=YOQWOUAi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032640AbeCSWht (ORCPT + 99 others); Mon, 19 Mar 2018 18:37:49 -0400 Received: from mail-cys01nam02on0090.outbound.protection.outlook.com ([104.47.37.90]:61852 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933456AbeCSPrf (ORCPT ); Mon, 19 Mar 2018 11:47:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=jKRPTK9J/fiTzn2zmGh2sk/J4pJpAFWG01gQvpZ3LkE=; b=YOQWOUAiMIAU4nhFvFUQDm+jdv4DfQtJoOGb6EE22gqtVthdY4RmVA3i5iGzR3+OWDOsBn6YNzYecqHngwJjvvrEO/CVQV04Ei2w43I/RrJ4a4nRacNTrbQsCd5U0klMlzX1FDGK6lASHunxQo1mox9lSvb3ndOSSE7Gpg5k9fA= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0998.namprd21.prod.outlook.com (52.132.133.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.631.0; Mon, 19 Mar 2018 15:47:29 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62%5]) with mapi id 15.20.0631.004; Mon, 19 Mar 2018 15:47:29 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: "Gustavo A. R. Silva" , MyungJoo Ham , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 026/124] PM / devfreq: Fix potential NULL pointer dereference in governor_store Thread-Topic: [PATCH AUTOSEL for 4.15 026/124] PM / devfreq: Fix potential NULL pointer dereference in governor_store Thread-Index: AQHTv5mUC4G7QjqkmU+d9/2pNkDkWg== Date: Mon, 19 Mar 2018 15:47:25 +0000 Message-ID: <20180319154645.11350-26-alexander.levin@microsoft.com> References: <20180319154645.11350-1-alexander.levin@microsoft.com> In-Reply-To: <20180319154645.11350-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0998;7:Rh7eZrwMHT7iQdbYYLM/wST67Wk3g6D23cU6na35aDAmM8ihGS2Suxz7fzvx45pzZTD2MNZC0Z0HAacVgX9+F+0NVPO3ySsh6R632VPgKyQXSnPIcAHq0x7q4XTGMPm77YZFRUQQWAGIEUypVa/OQ6NH6g2iD1S8z90WIVg1uufL3inTEqinw5Md30l1u1VxtsSXUpMRMWBedbHnpGhZg8bct6Gc8x/q+6tg6oMVR/fmo4wXfa5ON7lb5MXLT7VC;20:B/7iNB9yRDpyJOoBeP+FE6TxvM6CFIqG+T4xcaPEIakvGUMJRbxBQqvnlj1OhGWlPJGx5LfxrIFPxO8hEeF3jUX1E61+qGBy8slxXzDB6mVtQ+9xe9Si8s6wfwmM5124fHmwP8OWP6CteMAfP5ZpmCQjJaSBcwKUwOOcFnuVG2Y= x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 84912e9d-e6e7-4393-0af5-08d58db0b875 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0998; x-ms-traffictypediagnostic: DM5PR2101MB0998: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(7411616537696); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3231221)(944501300)(52105095)(3002001)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB0998;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0998; x-forefront-prvs: 06167FAD59 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(39860400002)(366004)(376002)(396003)(346002)(199004)(189003)(3846002)(6116002)(8936002)(6486002)(102836004)(68736007)(6506007)(2900100001)(22452003)(25786009)(3660700001)(7736002)(76176011)(6512007)(72206003)(86362001)(53936002)(8676002)(81156014)(6436002)(81166006)(305945005)(478600001)(99286004)(2950100002)(14454004)(6666003)(10290500003)(186003)(107886003)(2501003)(106356001)(26005)(86612001)(97736004)(5660300001)(10090500001)(110136005)(54906003)(316002)(2906002)(66066001)(105586002)(4326008)(36756003)(3280700002)(1076002)(5250100002)(59450400001)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0998;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: xi0cg7V+CN+x7+WL2rKQW6VCQUPOX95Nq3PLXR1RQffPjBJPFBfiy2eeOL6prZk5rpQjhcCA/LcoBPcWT9YHV8krpVnQT9F7zpsfg2FrqlybLBtEzYNIWtSKIAcGR3KdLIu2eiHNYE0+NQXt/l/LpYrZqy3E0x+t9exrnRHbr91e7iEKqxJAzGe2aronxl2wNwDlnRytnGcZN2L/AoPPeB40akx4uXyV1a2GxQ2XVSc6cL6JTpgHeRG+gN05fyJ2SqQgXruCDsLmrrITntPjrETVnyJt+Wi8rcvG3Y1Z7t9c/kyVlWI52/6aUqHcPLv4fyH4JAUVFGCmWIKk15mhag== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 84912e9d-e6e7-4393-0af5-08d58db0b875 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Mar 2018 15:47:25.8869 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0998 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Gustavo A. R. Silva" [ Upstream commit 63f1e05f7fe9ca509c60154d6a833abf96eecdc9 ] df->governor is being dereferenced before it is null checked, hence there is a potential null pointer dereference. Notice that df->governor is being null checked at line 1004: if (df->governor) {, which implies it might be null. Fix this by null checking df->governor before dereferencing it. Addresses-Coverity-ID: 1401988 ("Dereference before null check") Fixes: bcf23c79c4e4 ("PM / devfreq: Fix available_governor sysfs") Signed-off-by: Gustavo A. R. Silva Reviewed-by: Chanwoo Choi Signed-off-by: MyungJoo Ham Signed-off-by: Sasha Levin --- drivers/devfreq/devfreq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 99c4021fc33b..fe2af6aa88fc 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -996,7 +996,8 @@ static ssize_t governor_store(struct device *dev, struc= t device_attribute *attr, if (df->governor =3D=3D governor) { ret =3D 0; goto out; - } else if (df->governor->immutable || governor->immutable) { + } else if ((df->governor && df->governor->immutable) || + governor->immutable) { ret =3D -EINVAL; goto out; } --=20 2.14.1