Received: by 10.192.165.156 with SMTP id m28csp50495imm; Tue, 10 Apr 2018 16:10:24 -0700 (PDT) X-Google-Smtp-Source: AIpwx48sfnN8g519Ie6FsPC4cQ4hPj78Y3jqO9XcgMe0czuZpw8/mTDMFLwU9Kqw5OnMcN7mHWYG X-Received: by 10.98.166.196 with SMTP id r65mr1963620pfl.110.1523401824541; Tue, 10 Apr 2018 16:10:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523401824; cv=none; d=google.com; s=arc-20160816; b=z7/p+dgxL2Bb3EbCyLBvoVZWeP/Un/md6K3cLN9ytBSPVTyzRimWXaWXDKavlvziOD vkV7g4rst91M2tWiIKm4g4j+UJjS647pKE9WxwtadTxnQKQBmtVnRY/1/dACAw2+G4dr z7js2+uK/7e5QYfk99Ji7pOKkL8hGDxJSKdalvUH9BWBznlPZB2mmQo8pZPEFAm0xh4U ioflSzeHYf2k7kkZ4Mz1WDVmkDdJmiBULOwdVSElpFmHza0d+nRQJlVxyLxIlWfX9Lly xSb5nobQOqr/hmrJX8wnNf7x63dpce58XjWAHMqIbbdd6UYS+WCVEkZdK5UQ2kdwKGBT eRkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=d1GrlSHUdv8Nr7LDVeFjHbGcOotW+2/EPPARcTqywV4=; b=kdn25J33+mQy2yB5qrMpbuzFYExQxLqosq5LLF55gbQaWaZ23Edq23hxZNZG8hX8zP aKjsZUvkSFo1UYfsZkNh2lsE2UV+opQjUe+sNmVSd338C2GtfXK84bsmPuVo2g7IJJx0 6uUwhfCfyOMLNvCmojuR0N/GZn442HU4pJjgkH+6XC7JHf+PADR+r/kV5MA/bFn+eMMf TedVMH0KwrQNAqARCPEjk9JYwB6vQFLMCMA7kBGO/G2/krruzlDzxjJTtz0GFchelM+K FmRJgzzlBgNZWk06RhmOjq0+VmaBjg4dhja/RbDk0adUpr8GcU8kwPz7ULPMPbiZ/HJl qT/g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3-v6si3507823plz.179.2018.04.10.16.09.48; Tue, 10 Apr 2018 16:10:24 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755950AbeDJXFR (ORCPT + 99 others); Tue, 10 Apr 2018 19:05:17 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:41754 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932114AbeDJWe2 (ORCPT ); Tue, 10 Apr 2018 18:34:28 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id B308ED67; Tue, 10 Apr 2018 22:34:27 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Gustavo A. R. Silva" , Chanwoo Choi , MyungJoo Ham , Sasha Levin Subject: [PATCH 4.14 021/138] PM / devfreq: Fix potential NULL pointer dereference in governor_store Date: Wed, 11 Apr 2018 00:23:31 +0200 Message-Id: <20180410212904.578049322@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212902.121524696@linuxfoundation.org> References: <20180410212902.121524696@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- drivers/devfreq/devfreq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -935,7 +935,8 @@ static ssize_t governor_store(struct dev if (df->governor == governor) { ret = 0; goto out; - } else if (df->governor->immutable || governor->immutable) { + } else if ((df->governor && df->governor->immutable) || + governor->immutable) { ret = -EINVAL; goto out; }