From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5953115E97; Thu, 7 Nov 2024 01:50:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730944234; cv=none; b=P+yTbuAFCft+9TRF5sH8CF7M61aRSISxIAzAK3YwkxDfUeVmXHb6WMt1JcUTaXi/DC3MBQNR2itzf3xRhbitTelctfphZlbPxGvT+pQ2yluin/f/I1qNTIGn86/3gQ1fK64BLPsYlJSKo57vcUQR0/ZX/yAUuBu1EjsEGTbqFVk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730944234; c=relaxed/simple; bh=YJI1E8tmbz+Y93xMGa3xNqvVNAbjA65uJlkt7UQ4rsM=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=ROKUXojoZTIwQpsxi0yuX/2YoUHHH6kEcS7CejOYH0VF2sSVD0tLRnHqteBhsmi7AxS6XIFq2sOfdbNDcI4sZ4ZdE3XzFYkX760dXGOkcBszWYmOT7RYJQnk/i+sl5tMbybBVxud4/dw7C6vB8nO0VAnKL/zmGXTuOcErtX5+28= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.162.254]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4XkQ2G62Lkz10PTp; Thu, 7 Nov 2024 09:48:06 +0800 (CST) Received: from kwepemg200008.china.huawei.com (unknown [7.202.181.35]) by mail.maildlp.com (Postfix) with ESMTPS id E39FD180115; Thu, 7 Nov 2024 09:50:27 +0800 (CST) Received: from [10.67.109.254] (10.67.109.254) by kwepemg200008.china.huawei.com (7.202.181.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 7 Nov 2024 09:50:27 +0800 Message-ID: <786c90d1-29e7-72a7-acc6-394b3bbaeb75@huawei.com> Date: Thu, 7 Nov 2024 09:50:26 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.2.0 Subject: Re: [PATCH v2] PM: EM: Fix wrong return value in mtk_cpufreq_get_cpu_power() Content-Language: en-US To: , , , , , , , , , , References: <20241104113615.1397410-1-ruanjinjie@huawei.com> From: Jinjie Ruan In-Reply-To: <20241104113615.1397410-1-ruanjinjie@huawei.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemg200008.china.huawei.com (7.202.181.35) On 2024/11/4 19:36, Jinjie Ruan wrote: > mtk_cpufreq_get_cpu_power() return 0 if the policy is NULL. Then in > em_create_perf_table(), the later zero check for power is not invalid > as power is uninitialized. As Lukasz suggested, it must return -EINVAL when > the 'policy' is not found. So return -EINVAL to fix it. > > Cc: stable@vger.kernel.org > Fixes: 4855e26bcf4d ("cpufreq: mediatek-hw: Add support for CPUFREQ HW") > Suggested-by: Lukasz Luba > Signed-off-by: Jinjie Ruan Hi, could this be merged. > --- > v2: > - Fix the driver instead of em_create_perf_table() as suggested. > - Update the commit message. > - Add Suggested-by. > --- > drivers/cpufreq/mediatek-cpufreq-hw.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/cpufreq/mediatek-cpufreq-hw.c b/drivers/cpufreq/mediatek-cpufreq-hw.c > index 8925e096d5b9..aeb5e6304542 100644 > --- a/drivers/cpufreq/mediatek-cpufreq-hw.c > +++ b/drivers/cpufreq/mediatek-cpufreq-hw.c > @@ -62,7 +62,7 @@ mtk_cpufreq_get_cpu_power(struct device *cpu_dev, unsigned long *uW, > > policy = cpufreq_cpu_get_raw(cpu_dev->id); > if (!policy) > - return 0; > + return -EINVAL; > > data = policy->driver_data; >