Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1104407ybn; Tue, 24 Sep 2019 14:55:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqxIKyqqd/59f0/40m62zZIZBytcwOP3YT+QUmWQIiWwwel7vaeT8rO4TgP6gN+iog7UnSPV X-Received: by 2002:a1c:4886:: with SMTP id v128mr2836496wma.176.1569362138696; Tue, 24 Sep 2019 14:55:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569362138; cv=none; d=google.com; s=arc-20160816; b=X21YflGWWnp8KMJSoGnENENjS7DYuU3UWfhzPsnCCeN4MN1pQXaKAcH6KPjmnDCvih nzYXl1Wj4XuoYIo+SLOTNtZRtzKameej+Oz+JUtguszH5r4GcTkNExLDMFfGwXMk6XZ/ +pB8FtYrdFDtvW19Z+vc8FUMxegX5/QtNRqXQa2DJfGA1UF7SB9X6JuEnKfc3vF/EKWL 1FhZ3loRdLXaBFe7Ffex93dwjtzkvsjUMnjPWshCavKAP97p+A7mB+ULndD9MuvNiWEa OM7pe6ZhGsKp8vaHftQSTm3b5ghZ4G+GdFYVCC/oLAMHpUgzVtqDhvjutWH1j4+hnGLM BUlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6a+ixqdzAJ1M9wB1o4NKc1vK9TBNDV6mYtep3CLoV2A=; b=uyDv/lFg0XTBTXAjDOjMaI6yxFCN6H2+NJwKivfHH2rlqOlspNRoitljvm9I7rTRtF kzz0W96nxmE/wqDCJL9p338sNG/BUX+JG2QKwHjwSV1S1apFk9jFZ310uUUriXyDGm4J EEMV9tEU8WRzkBxU8onQeWOr/ZfUPOV+6GhSN5SYclUQr0uqK2INt7XgIc2V6Mr2bnmn RSVujguCa/19/yqp0rl90K/7Xqu1IAgBU4IHJlDG4hW8dLppKe0oexVw76sWxk0yHHz7 67XP3oEp9az2rTRPS5C9AbK69hu2jCJfVUtAa7z0dENMv7FWu/ttHviuj8ypcvsQP0hI WSQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cOgpsdGo; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f45si1892749eda.345.2019.09.24.14.55.15; Tue, 24 Sep 2019 14:55:38 -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=@kernel.org header.s=default header.b=cOgpsdGo; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438719AbfIVTeR (ORCPT + 99 others); Sun, 22 Sep 2019 15:34:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:43736 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390694AbfIVSrT (ORCPT ); Sun, 22 Sep 2019 14:47:19 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F020A208C2; Sun, 22 Sep 2019 18:47:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569178038; bh=J2I7SM7bMsl2OQ6fr2CABIWGTg6EorLiy5htaNXQeuo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cOgpsdGoqyFkmq5wjJja/3a0Q9y7mnhWj2miGUkWkh8N3rMujaHVZQmKEA2RPSV5Y XZ7jVUmOMfcQ6ewhvx6DZYIs8H6y/+W2QUHPQFeilupQaP6xGiERGS4eCbSq7J5Gjj pkHunALJ5kzjLRSak0+K5+Fxbe0sR9EyHJsxqUfo= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ezequiel Garcia , Chanwoo Choi , MyungJoo Ham , Sasha Levin , linux-pm@vger.kernel.org Subject: [PATCH AUTOSEL 5.3 119/203] PM / devfreq: Fix kernel oops on governor module load Date: Sun, 22 Sep 2019 14:42:25 -0400 Message-Id: <20190922184350.30563-119-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190922184350.30563-1-sashal@kernel.org> References: <20190922184350.30563-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ezequiel Garcia [ Upstream commit 7544fd7f384591038646d3cd9efb311ab4509e24 ] A bit unexpectedly (but still documented), request_module may return a positive value, in case of a modprobe error. This is currently causing issues in the devfreq framework. When a request_module exits with a positive value, we currently return that via ERR_PTR. However, because the value is positive, it's not a ERR_VALUE proper, and is therefore treated as a valid struct devfreq_governor pointer, leading to a kernel oops. Fix this by returning -EINVAL if request_module returns a positive value. Fixes: b53b0128052ff ("PM / devfreq: Fix static checker warning in try_then_request_governor") Signed-off-by: Ezequiel Garcia Reviewed-by: Chanwoo Choi Signed-off-by: MyungJoo Ham Signed-off-by: Sasha Levin --- drivers/devfreq/devfreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index ab22bf8a12d69..a0e19802149fc 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -254,7 +254,7 @@ static struct devfreq_governor *try_then_request_governor(const char *name) /* Restore previous state before return */ mutex_lock(&devfreq_list_lock); if (err) - return ERR_PTR(err); + return (err < 0) ? ERR_PTR(err) : ERR_PTR(-EINVAL); governor = find_devfreq_governor(name); } -- 2.20.1