Received: by 10.223.185.116 with SMTP id b49csp319043wrg; Tue, 20 Feb 2018 22:01:52 -0800 (PST) X-Google-Smtp-Source: AH8x227m8d9gVQfwA3LkOCdITO5wUtDUKSgMpJj6hAcxOL1otGI2Y0RA1+Ut7vfEHnEC6I47wIr9 X-Received: by 2002:a17:902:50e:: with SMTP id 14-v6mr2076614plf.360.1519192912291; Tue, 20 Feb 2018 22:01:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519192912; cv=none; d=google.com; s=arc-20160816; b=D1JBRGsPgQcB+8VeFjV5tZt/tI9VpnhK7sNz0Or2zthFfsLdwqyo9z9PLZZA5wHWpC qjSUEW6S0DGNrW3Kdn6dyyo5oTVQ9btLahqpiJ5jsSRUGpTd+h6XqEcRJQDA0Z6q5NTh leZLx4sj8dTiyR/623HOTEq2B51m0ZgA1EoSlPr/nGH4RzEzwcU9mmeDHHKPf33bPsSA +sHesoquAWmridc+xdnGEz+jhIIKAmiQmnuRWBy9E7nmOzXlu4d7pouwfgw61CD9TG4a 5HJh89r9tXw0U2Kl2ZkJcIxrpWDEpzMDokFHYpA80hx3edOhX8Q4sS3jyZxh56RtmHZ6 TXpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=mVl8Es3KA1CrPsxvzGnsXXim3/z2bRfOw2a2MbgTsgc=; b=UNY8P2Ma/p3MqkKEPV4cG5K0uasJk0e1LCYJHRL/RiZ72O29fpAGG5hBE3QAsK1Be3 PUI+aVKe5lkKr1XMsrtfLqYRrsFEhvWV1C5G72b9nX1PdkqqbRfGIvxEs23i6Mshf579 Ek54KmHh5v048EuBQt1fxD2CeozQcmkafwTW8/MOtXGYLhwjCVH0HlJiiitlbkP7/XE4 hE7zQXk7EnXCS57p++otPp9jo5GNgT5GLnQZJc7nOpXe9HiYOg8uuj8J4J3ovqlAkqFr Xuq4aHmSWs66oNvbFNbTAEIG18149tkNcwzQ/gmts9VVU0aCRRiPAewzTw+bJ3a5B0JK utow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TzwHz4qQ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 185si2058758pgj.636.2018.02.20.22.01.37; Tue, 20 Feb 2018 22:01:52 -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; dkim=pass header.i=@linaro.org header.s=google header.b=TzwHz4qQ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751549AbeBUFyz (ORCPT + 99 others); Wed, 21 Feb 2018 00:54:55 -0500 Received: from mail-pf0-f173.google.com ([209.85.192.173]:40468 "EHLO mail-pf0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751369AbeBUFyy (ORCPT ); Wed, 21 Feb 2018 00:54:54 -0500 Received: by mail-pf0-f173.google.com with SMTP id m5so283157pff.7 for ; Tue, 20 Feb 2018 21:54:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=mVl8Es3KA1CrPsxvzGnsXXim3/z2bRfOw2a2MbgTsgc=; b=TzwHz4qQMyBYjovDPvkkAFEQfHMJg17W76KloHfwQ1QADx0UvNNUvGvHoxYbZrhh2W NmdOWRmkwuyF5BrSlAux+gj7ECUZ2aNd1OjFaSFiH8SmSMGOmnOM3OJPm+XV56MvmSyX +dj7CyJtL3XLoIDXSJUhtZNKEZmU4RC11/MLk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=mVl8Es3KA1CrPsxvzGnsXXim3/z2bRfOw2a2MbgTsgc=; b=szLHiAz6TN8Uwu7j8zIYvUq3Mgkyyzo1yyBWi+SjW7CkO2X7It3lRZ1oCH8AFJ14Yg pUkSi0L9MIjw84taA+xOoPjVVhgFyg5KDMRZVwBC6RJXn29WYVTLjYrCPAKL4JSSYE4+ F6FgkRzmzgkcA3h5L0afGj+TDGQwQUKWk0Z7Mmj2KOQYHUwK1ryoRQZK8sjYj/yY5u0a /m9CJqTtmEC2pWvo7bNrAO0dwVtzt0gPZJXQddcCoW15/nehr1V5867SnG84FDouLknm wE0J14L7S6kx5y5eVCfGjWbBOr9alhfB11Rq1Blpt9OT7qjioDwAXO34aqEdUSuuELqV J/Hw== X-Gm-Message-State: APf1xPDl6LGfQ5fgEpdYUJ8S1+SoNPJ6+EQGjgINpClJlhm48yRhG4GS vzkE+4idGwP6vwM1HPAab+oFzQ== X-Received: by 10.99.143.13 with SMTP id n13mr1823266pgd.105.1519192493765; Tue, 20 Feb 2018 21:54:53 -0800 (PST) Received: from localhost ([122.167.232.138]) by smtp.gmail.com with ESMTPSA id i1sm10919603pfi.116.2018.02.20.21.54.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Feb 2018 21:54:52 -0800 (PST) Date: Wed, 21 Feb 2018 11:24:50 +0530 From: Viresh Kumar To: Michael Ellerman Cc: Shilpasri G Bhat , rjw@rjwysocki.net, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH] cpufreq: powernv: Check negative value returned by cpufreq_table_find_index_dl() Message-ID: <20180221055450.GO28462@vireshk-i7> References: <1518430876-24464-1-git-send-email-shilpa.bhat@linux.vnet.ibm.com> <20180212102900.GU28462@vireshk-i7> <874lmasxxx.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <874lmasxxx.fsf@concordia.ellerman.id.au> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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). > Or if you ask for a target_freq that is higher than anything in the > table. You will still get a valid index in that case. There is only once case where we return -1, when the cpufreq table doesn't have any valid frequencies. > Or the API changes, and we forget to update this call site. I am not sure we can do much about that right now. > If you're saying that cpufreq_table_find_index_dl() can NEVER fail, Yes, if we have at least one valid frequency in the table, otherwise the cpufreq driver shouldn't have registered itself. > then > write it so that it can never fail and change it to return unsigned int. But what should we do when there is no frequency in the cpufreq table? Just in case where a driver is buggy and tries to call this routine for an invalid table. > Having it potentially return -1, which is then used to index an array > and not handling that is just asking for bugs to happen. I understand what you are trying to say here, but I don't know what can be done to prevent this here. What we can do is change the return type to void and pass a int pointer to the routine, but that wouldn't change anything at all. That pointers variable can still have -1 in it. -- viresh