Received: by 10.223.185.116 with SMTP id b49csp1021712wrg; Wed, 21 Feb 2018 10:42:40 -0800 (PST) X-Google-Smtp-Source: AH8x227c/irhCG6RDnnsVJUaDv+Pkzh+Vt4H9bnmn8XGZHZLI8KL1vOAKwq8+V9zpc1FVtx1mj/h X-Received: by 10.98.7.73 with SMTP id b70mr4158690pfd.39.1519238560379; Wed, 21 Feb 2018 10:42:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519238560; cv=none; d=google.com; s=arc-20160816; b=FWeMjsORi6siHpYwaKTtoTOwFr6p/B2clibTB3R12YIcRyccB5Fp6Cmzn1+amja9n8 ZRGwbmeQbO0oD36kuzxaMxLWtEEPoTaT18Fo5CywIabBteKewHBm/aqDlka3+navrhek r56ItM/mAfS2dXmT2L8DhgtVy6e3BnEadAZBa8D45hlHdfx1hAQS0YLH0kBqeh3hxs0R Sd5Ow/qvn2ns9ry+Sre4fK29SjGB1L9oVwUmZiKQ4nESX3cYsWoS8nda5V7wb3sVOhCV 0fEDzwIyogI8r3g1ppyEaFlcKbNgRBqf3vqb/g4s0xRKo40j2iJpCXnnKC7G7vFlEPeE s/TA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=ODxjYDIHoV5OKAletdAWKNH8B9+SrMKNU9nRyyKsVcs=; b=miQaD7fsEWpez6Zf5WWXaPjrEmIroZvA/kwMulUbgoyzGL0nTxFPA7RORjZhZ3o9CL gIKcZHWmBvZODt1Bmwybj74Lai8MwcTNpbVIvmsfIIpMM5BhiPsDekXgB+GTpFGoFq/D Id26YwDcUl2dDbsjeBKsUPa3AXN9bSwaXUGOReaaSmxIEUUFiQVB+oAFfIhq/31D+HO8 fnvqSb4U1gb3FYWQVZH6Baa3MGxyff0MYEu1PbeJG7oaQ02a2Y8u0EnUVJxaj/DZTYmf Ys43MkbPgWcShlFpwahc982DVvvj9v8g4IKGL+U78hAY/VSvFsEFuhzlipSZKJzrXKw3 F6Dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=TBK9TG6p; 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 u3-v6si9455695plj.207.2018.02.21.10.42.26; Wed, 21 Feb 2018 10:42:40 -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=fail header.i=@gmail.com header.s=20161025 header.b=TBK9TG6p; 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 S965777AbeBUNZO (ORCPT + 99 others); Wed, 21 Feb 2018 08:25:14 -0500 Received: from mail-ot0-f173.google.com ([74.125.82.173]:44629 "EHLO mail-ot0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932126AbeBUNZL (ORCPT ); Wed, 21 Feb 2018 08:25:11 -0500 Received: by mail-ot0-f173.google.com with SMTP id 79so1357940oth.11; Wed, 21 Feb 2018 05:25:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=ODxjYDIHoV5OKAletdAWKNH8B9+SrMKNU9nRyyKsVcs=; b=TBK9TG6peNifpyW85fjvTlc6DuCauvDw6Sy0E/CK/xikkir6BXfGwAVbQeVjZKwxtN o4qdkdVhAsDG1/W4GE0V9KzdUhh3HkpeHTp8rfrPWG8aaCQsUiy0XQp3VTghdkua+TG4 iU+U7yzdWBHpQ1vnlMET3bk8tojUxHBamT8BpxaLbEenkbTIJavC8c8yaXi1lw01tcyI C/SAblq9qITtgyh9a1JwJGmnZqaY4pzt11g7Tn1FEjh4uz2zuv8iD/ATXbT/GLRzm22+ Q7QG4N0t7DUctLKDIQC5gP1sx7o1RmiVxV0ji7y57QFB/YnZx496i3/Qs+lbq9vuIHPM gaJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=ODxjYDIHoV5OKAletdAWKNH8B9+SrMKNU9nRyyKsVcs=; b=Q8E4nxcpoPlTxPYGVvjuf/kjs9DgCsgpV4KnsItnnBRh7HYBLgJj/k9qp50FJrNffv kpXhYDuA1gD41zThgsjVk0DAlJQl9U5II+a1Hf48+d9qBgCSQm5lQKwrcq82iyO3Ra8/ xbdDQwM5Ez7rrwImeYJ8BzvwWtoRWy9aIkUOVsKjCULtrE4ozf7FVHNHUWx2w/o+VZqE tXUOwsDL5Q9k4usAzAtzihumpEG5imeCcOoJTpqR8zaZ3Q/9I16pa99zytszb2JWaE8/ PtEyCYtd8KLkzVRBbhoJJA9+gZitpIlwa62vrNXsR5sKdqyHUwNZC4zzIMOELBmc7JIY E5/Q== X-Gm-Message-State: APf1xPAOYPFcxRZ5gOrORlVzRobCep2OISFg4QrJzz0Kb0YU1cZHMuM7 ztcQjiJpCCUhlcxZ4CF45KS/f1yj25E57F0Ka3E= X-Received: by 10.157.40.101 with SMTP id h34mr2239423otd.364.1519219511062; Wed, 21 Feb 2018 05:25:11 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.44.146 with HTTP; Wed, 21 Feb 2018 05:25:10 -0800 (PST) In-Reply-To: <87vaeqqye8.fsf@concordia.ellerman.id.au> 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> <87vaeqqye8.fsf@concordia.ellerman.id.au> From: "Rafael J. Wysocki" Date: Wed, 21 Feb 2018 14:25:10 +0100 X-Google-Sender-Auth: Cew4bkNtXHxwEF8A9kLpyqzV_MI Message-ID: Subject: Re: [PATCH] cpufreq: powernv: Check negative value returned by cpufreq_table_find_index_dl() To: Michael Ellerman Cc: "Rafael J. Wysocki" , Viresh Kumar , Shilpasri G Bhat , "Rafael J. Wysocki" , Linux PM , Linux Kernel Mailing List , linuxppc-dev Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 21, 2018 at 2:13 PM, Michael Ellerman wrote: > "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). Well, let me rephrase. If ->fast_switch() runs, then it must not be possible to get a negative index in it. That has to be guaranteed by the core.