Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3386631yba; Tue, 23 Apr 2019 02:57:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqz1i/wVb+jEO8Qhc6Tgiv9N7SdT6KAulWLeX299J/QKMISLOCrpbHND85P8u5mackg/N9l0 X-Received: by 2002:a17:902:280a:: with SMTP id e10mr25559726plb.244.1556013428547; Tue, 23 Apr 2019 02:57:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556013428; cv=none; d=google.com; s=arc-20160816; b=EDw0dUgeCApkJZMdbocMvdQm7pGhah4u2t1JOC/8F4kH9X72T2QDbY5w+ziBt7wfoC nF1mKOizqB2D3RdL7R1qYTxJvtaTNW/vC/hcJFaKj7+r1rF3odbWtr1PMXH1zy/0Z4yn L+bzU97z5Ldd08814CN26WXmgyKXPE/M4PWAd2lMbAqqV62oNdLdlSeNoO41VLG7gCCa Y1lc81fbJZI+XLot19a2ohe5G3WqTNVIrT+31pDgCsPSvVaTQg7jNuMGPzqB0y3ruMkS iMZtlDgASatIK9e7VfXShjqwFVurEl4m2qo6Lje8FoDvSHZio3UXm6fzoGVOr9VNu9bX zULA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=JTtJbbOQee4Mej+4AkUax6n+eIZREZQk9ZluQVPNCJM=; b=laNp9S6qLRP9q4bjrVevNGhsM/Y2Rx4MxdRhmNbIwSPU23fRbD4efWFP4HYkQd9qQ1 q+wea7R2c5jWBYWftTfdOwvALf8V5avfde0VbJpi7Y1E84dPuACFs9B7dnb9g7u5asMv 7NOFJlt2at0RLEimHDwNn5wWddeeogSMS0SOCALGoZO/99AP8Zh5Yv4kq50+/TiiAWcJ f1MTrkrZErQv2uV2n0UMQTdWZqudmP62UVdIw8DxOAhrSYsbfv7JPv0pDVqJSYmt7v4O XLFJX+4Mn3y3f3cgzfX9AniWvYZ2hiteAssE9ELTc/ijSOoiGQxKeNmyYMXsBaDZnkW1 LMrw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f64si15976836pfc.168.2019.04.23.02.56.52; Tue, 23 Apr 2019 02:57:08 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726586AbfDWJz5 (ORCPT + 99 others); Tue, 23 Apr 2019 05:55:57 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:50890 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726150AbfDWJz5 (ORCPT ); Tue, 23 Apr 2019 05:55:57 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id F38A427FB1F Subject: Re: [PATCH] PM / devfreq: Return -ENODEV from try_then_request_governor To: Tomeu Vizoso , linux-kernel@vger.kernel.org Cc: Alyssa Rosenzweig , MyungJoo Ham , Kyungmin Park , Chanwoo Choi , linux-pm@vger.kernel.org References: <20190423081158.29859-1-tomeu.vizoso@collabora.com> From: Enric Balletbo i Serra Message-ID: Date: Tue, 23 Apr 2019 11:55:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190423081158.29859-1-tomeu.vizoso@collabora.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Tomeu, On 23/4/19 10:11, Tomeu Vizoso wrote: > Callers don't expect it to return NULL, but an error code. > > Fixes Oops such as the one below, when one tries to set a governor that > isn't available: > > Unable to handle kernel NULL pointer dereference at virtual address 00000018 > > [] (governor_store) from [] (kernfs_fop_write+0x100/0x1e0) > [] (kernfs_fop_write) from [] (__vfs_write+0x2c/0x17c) > [] (__vfs_write) from [] (vfs_write+0xa4/0x184) > [] (vfs_write) from [] (ksys_write+0x4c/0xac) > [] (ksys_write) from [] (ret_fast_syscall+0x0/0x28) > > Signed-off-by: Tomeu Vizoso > Fixes: 23c7b54ca1cd ("PM / devfreq: Fix devfreq_add_device() when drivers are built as modules.") > Reported-by: Alyssa Rosenzweig > Cc: Enric Balletbo i Serra > --- There is already a fix for that. The fix was initially sent in October [2] but unfortunately it got lost. I resend and now is queued [1]. Hopefully the Fixes tag will help to pick the fix to the proper kernel releases. Thanks, Enric [1] https://git.kernel.org/pub/scm/linux/kernel/git/mzx/devfreq.git/commit/?h=for-next&id=b53b0128052ffd687797d5f4deeb76327e7b5711 [2] https://lkml.org/lkml/2018/10/16/744 > 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..5539e9be718d 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(-ENODEV); > > governor = find_devfreq_governor(name); > } >