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=-9.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,USER_AGENT_GIT 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 8A47FC4360F for ; Wed, 3 Apr 2019 15:26:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 649E6206B7 for ; Wed, 3 Apr 2019 15:26:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726544AbfDCP0O (ORCPT ); Wed, 3 Apr 2019 11:26:14 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:43126 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726084AbfDCP0O (ORCPT ); Wed, 3 Apr 2019 11:26:14 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1A9D0A78; Wed, 3 Apr 2019 08:26:14 -0700 (PDT) Received: from e112269-lin.arm.com (e112269-lin.cambridge.arm.com [10.1.196.69]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DA40E3F68F; Wed, 3 Apr 2019 08:26:12 -0700 (PDT) From: Steven Price To: Kyungmin Park , MyungJoo Ham Cc: Chanwoo Choi , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Steven Price Subject: [PATCH] PM / devfreq: return PTR_ERR not NULL in try_then_request_governor() Date: Wed, 3 Apr 2019 16:26:02 +0100 Message-Id: <20190403152602.10019-1-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The callers of try_then_request_governor() only test for a PTR_ERR using IS_ERR(). However in the case that request_module() fails then NULL is currently returned which will cause a NULL-pointer dereference in the caller. Instead convert the error we already have to a valid PTR_ERR and return it. Fixes: 23c7b54ca1cd ("PM / devfreq: Fix devfreq_add_device() when drivers are built as modules.") Signed-off-by: Steven Price --- 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 0ae3de76833b..d29f66f0e52a 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 NULL; + return ERR_PTR(err); governor = find_devfreq_governor(name); } -- 2.20.1