Received: by 2002:a05:7412:bb8d:b0:d7:7d3a:4fe2 with SMTP id js13csp1530699rdb; Wed, 16 Aug 2023 14:30:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE9D8tL3xQNUi4nPQZCAJqNjmxsMZxkV9rJD870ZIzQ7MNxhT1RSucR14opSXi5Q19vu5b/ X-Received: by 2002:a05:6808:1316:b0:3a1:dd99:8158 with SMTP id y22-20020a056808131600b003a1dd998158mr4452797oiv.6.1692221445879; Wed, 16 Aug 2023 14:30:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692221445; cv=none; d=google.com; s=arc-20160816; b=guSXhlcoHudv+zPV5oTVAZ/5i4AkcL20S1N6e76t649PFD8HFU50zDg7qdiy8twRA8 gfGD0HWC2Qj6ARzGvyCl6CeiK667ui8CBRzrO8Mi6U25VALf93NGMcw2J4lrIdWDqBk6 gLwbeKjpE6PdnBYj8GCgeDzcP7woFbsm/1UYTTSU21KuI9AiYA5i3+Y/PpEhW+DU5uHH ew1pI00UHkII3J/x/Ku2QvCgx2EZhP8GBr48MxgKj+qrbz3p+UESPJcQci7Bdet/S5Df 5FbxF2KlJxwLMwKMWE6M1/aQSySyaFtoqk9v99N25B22OQJxpoZNuHZI0uvVcuV8UeUG 8gHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=l6acSGcoTdVkXKlNxFnnJnM91Y3gAPB3GGQRDJi6Okw=; fh=zL0RJJbWGhtGViFoY08GZ7xRTleYWZrAT7mNooLCENE=; b=galPfdeu33UGyWFfKeV5IgM8sT6oOtxd0juCaJcxWoeb9idrJg7n6vWksvs16Gb+fM m0mWg5w8fQt2ecpKPMDO1ukuypHVuY7IghU8l3EOW1blUrqdtgs1GYubSPkZkFFnXldi ge35LobkEXlfJwqCU6E5TemWC7Gh0Tyhvg8gkI0CAPXS2c6wN/TWwseXgo1I14aY3F6y lq3nEgF+6Cu6MqMyETKJVSD9rrI+M+j5Ij5NAwuwsJArS+4ohCcAHKytNsszfJ2ze6QC cyJHnVm5BwLl2PLWEQuqKfipJQGCIIG2mct+BDLuObbHozsvYTUhmOxt/7dqZ1LWQUBS DDWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b18-20020a63a112000000b0056532fbe293si12017372pgf.323.2023.08.16.14.30.33; Wed, 16 Aug 2023 14:30:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242411AbjHPH1q (ORCPT + 99 others); Wed, 16 Aug 2023 03:27:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240063AbjHPH12 (ORCPT ); Wed, 16 Aug 2023 03:27:28 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D0E0C1; Wed, 16 Aug 2023 00:27:25 -0700 (PDT) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RQfkn5RDNztS1S; Wed, 16 Aug 2023 15:23:45 +0800 (CST) Received: from [10.67.110.108] (10.67.110.108) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Wed, 16 Aug 2023 15:27:21 +0800 Message-ID: <8fea501c-b950-17bd-c710-c923b9af6e62@huawei.com> Date: Wed, 16 Aug 2023 15:27:21 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.11.2 Subject: Re: [PATCH] cpufreq: cppc: Add missing error pointer check To: Viresh Kumar CC: , , References: <20230816030549.849824-1-liaochang1@huawei.com> <20230816034630.a4hvsj373q6aslk3@vireshk-i7> From: "Liao, Chang" In-Reply-To: <20230816034630.a4hvsj373q6aslk3@vireshk-i7> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.110.108] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Viresh, 在 2023/8/16 11:46, Viresh Kumar 写道: > On 16-08-23, 03:05, Liao Chang wrote: >> The function cppc_freq_invariance_init() may failed to create >> kworker_fie, make it more robust by checking the return value to prevent >> an invalid pointer dereference in kthread_destroy_worker(), which called >> from cppc_freq_invariance_exit(). >> >> Signed-off-by: Liao Chang >> --- >> drivers/cpufreq/cppc_cpufreq.c | 21 ++++++++++++++------- >> 1 file changed, 14 insertions(+), 7 deletions(-) > > I think why it was designed this way was to make the driver work, > without invariance support, in the worst case instead of just failing > completely. The invariance thing is a good to have feature, but not > really necessary and so failing probing the driver for that isn't > worth it. We should print all error messages though. > Thanks for pointing that out. I think you are right that the kworker created in the cppc driver is not the only arch_freq_scale updater, the ARCH provided updater has more priority than the driver, so the driver should still work even without kworker_fie supports. If that is the case, i think the best thing to do is checking the error pointer and printing an error message before calling kthread_destroy() in cppc_freq_invariance_exit(), this is because at that point, it is really necessary to ensure the kworker_fie has been initialized as expected, otherwise it will raise a NULL pointer exception. I hope this makes sense, thanks. -- BR Liao, Chang