Received: by 10.223.185.116 with SMTP id b49csp1019407wrg; Wed, 21 Feb 2018 10:40:21 -0800 (PST) X-Google-Smtp-Source: AH8x226Lvj7diqtOETbEcwNp14fbqOW6Yi/KFBNJIONdwOMrlrCFIihrOc/OImuLy7vMedZnYLmF X-Received: by 10.98.100.131 with SMTP id y125mr4194353pfb.117.1519238421104; Wed, 21 Feb 2018 10:40:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519238421; cv=none; d=google.com; s=arc-20160816; b=cYLHBVnzyV/Ql7mS4h+pArHrflLLMM6+0n1D9acI4W86mk3UEqSMLT5RAFtw+Fur3z 5AneK0alXZPbpnFMsn2OOt+IX71z1MH1+nFcpWpKiwDdV4lYpppwAGmVeKQw2yHq5Bqn AUDYnMPM4gwSJlFBs0gh6RfYmeWF1GnuvujZ7R2MFqgiKJBdkiSPsu513eBGs63+yQFq H3DRL/0Cb4KHsx5A4E1rSz38WFolA3ErcP6gD3bQcgqvfmJ8iaHd1Ib2LkmNK1CxogGW GMPaUq8nwOv+Q9GHuv3DoGY2930ox0eHt8ybw2Q3niiRrKwAYZ4ErRv8rpBtiUvX1XAw Q6EA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:arc-authentication-results; bh=psHIKMU/4DixJ6VN9l26aeejyYLpfb1ZOCO453Wvb8k=; b=MungUPw8LHF270PAoQiRUIg73IycJWFMGAh/AbcaUhcuznO7jb4KYqlZZZlwgHV5qC Dsf/CVUE3bPr6wy7hw8tXIYsr9VUsLaOgVrw52b17uvOhuX9n+ushTNx7AQocPNwvvd6 NeLh0r3N1wMCyAqoZlRoUiR19ZErMJk/FVZuaPb5TaSh1ger5lML2DPfSaB88EKzn3iy 3NyR3j4b3xLlb+RBwZkcDIRvfrpRAJuwoHQej9urfb6Sb19FD/iEPjR8z9HJstoP/+/e kX+O/AEurd2q+9wGy+bJY+v9rutwP0tM0ZK9H89scg4mU2+xB+xQOXeeSQy/3s5tiNaS D3VA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z4si7292443pfh.138.2018.02.21.10.40.07; Wed, 21 Feb 2018 10:40:21 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936501AbeBUNPq (ORCPT + 99 others); Wed, 21 Feb 2018 08:15:46 -0500 Received: from ozlabs.org ([103.22.144.67]:59407 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754542AbeBUNNJ (ORCPT ); Wed, 21 Feb 2018 08:13:09 -0500 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 3zmdFv4KxCz9sZG; Thu, 22 Feb 2018 00:13:07 +1100 (AEDT) From: Michael Ellerman To: "Rafael J. Wysocki" , Viresh Kumar Cc: Shilpasri G Bhat , "Rafael J. Wysocki" , Linux PM , Linux Kernel Mailing List , linuxppc-dev Subject: Re: [PATCH] cpufreq: powernv: Check negative value returned by cpufreq_table_find_index_dl() In-Reply-To: References: <1518430876-24464-1-git-send-email-shilpa.bhat@linux.vnet.ibm.com> <20180212102900.GU28462@vireshk-i7> <874lmasxxx.fsf@concordia.ellerman.id.au> <20180221055450.GO28462@vireshk-i7> Date: Thu, 22 Feb 2018 00:13:03 +1100 Message-ID: <87vaeqqye8.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org "Rafael J. Wysocki" writes: > On Wed, Feb 21, 2018 at 6:54 AM, Viresh Kumar wrote: >> On 21-02-18, 16:39, Michael Ellerman wrote: >>> Viresh Kumar writes: >> >>> > AFAICT, you will get -1 here only if the freq table had no valid >>> > frequencies (or the freq table is empty). Why would that happen ? >>> >>> Bugs? >> >> The cupfreq driver shouldn't have registered itself in that case (i.e. >> if the cpufreq table is empty). > > To be precise, ->init() should fail as that's where the table is > created. The registration fails as a result then. > > But what if the bug is that ->init() doesn't fail when it should? > > I guess the core could double check the frequency table after ->init() > if ->target_index is not NULL. > > The overall point here is that if you get a negative index in > ->fast_switch(), that's way too late anyway and we should be able to > catch that error much earlier. OK. Still it's one thing for the driver to print a warning and bail out, it's another to access off the front of an array and keep running using some junk values, or oops (though not in this case because the array happens to be static). cheers