Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3917331ybl; Fri, 20 Dec 2019 18:44:01 -0800 (PST) X-Google-Smtp-Source: APXvYqxCu4zc5+OvoPZBK1XKFRW4W8b3m5ciIsJgQrLGPs6syYBKNOmaQ7UcBMahlib0+/4YK2/f X-Received: by 2002:a05:6830:304b:: with SMTP id p11mr18460296otr.338.1576896241237; Fri, 20 Dec 2019 18:44:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576896241; cv=none; d=google.com; s=arc-20160816; b=zrcsaKF19L1c8GKQ8/9OFCqmZrG8S973F4oCHOBj5Us1sqvkKVAX+PLN4SAHtj9GMT UtGbVsXzXOUH855BBOFL74yZ/jM+0TJWrGDpn1yZZIUWGt9sVxYJ03RA9JCikZWIDVAa QoRI3oo662MmhF6nvrhV/vtfW57F5H9XacEQ9/Jo4q0xiSksxC0UyCR/9+SCZR9XSiqh aEv4mMv1Sl6k3MZgWI7gruxCuErikk97D5hWs3QktYPVlWpVJJrorXIQ9lfPlDYcxE0M 2DGU76afCR1CiydifWIL9cSYPQzhEQtPe8lUi8nvHrVsH2gd1oPGAnJoqmjrfkVnUz0T pcUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:date:message-id:from :references:cc:to:subject:dkim-signature; bh=aG/6VJAuRbFI92ikmGfoMv9gEFQfb1tWIpO7XSYMEwY=; b=k9V1u0w+zhoNlKYoQo3vRFIlzkxMVMhyaXDSdZIMktVeut3pTafiDIFbfcOXebBN++ R/py8UfUeRdtFA2E8ZuNI/Gdt5bBq2IKjO3ZSWU6/bV4n9MeQy/5RNzG39gTfOKA1YB2 IZece9Q31kXJ4qwXO3Oc0RD7sMSKAOn9K0Zqr2jMyvj0vFZiOCQnL2e2gRRDA4T5ScGs ge6trMd+aPhQhrgBB1V+dRClDGlAYiDyrIK6evoUpC5Dx3rzZ9e1HgAcApUIdtRravNQ i9NgagkCsHT7PdJlgJ09LO/+cDgcfH984yW+ikyHJyauIo0fEjD6n5z24qM6pc/k1+ja HBlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=raPYXzxE; 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 65si3990625oif.14.2019.12.20.18.43.48; Fri, 20 Dec 2019 18:44:01 -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=raPYXzxE; 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 S1726671AbfLUCnJ (ORCPT + 99 others); Fri, 20 Dec 2019 21:43:09 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:37763 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726598AbfLUCnI (ORCPT ); Fri, 20 Dec 2019 21:43:08 -0500 Received: by mail-wm1-f66.google.com with SMTP id f129so11055407wmf.2 for ; Fri, 20 Dec 2019 18:43:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=aG/6VJAuRbFI92ikmGfoMv9gEFQfb1tWIpO7XSYMEwY=; b=raPYXzxEMBq0yPsUt53IzQ1XbYLgoMqNAuNlDTIQ6VF95rrzkYFjuW7X9bKx8Un5PD dQ93JBqPt6iO+VlffXlKz2KJU4CkXmi8rVH1+Elj3AAzgtfIOSeCgEKxoC964Z4v6gZ6 gdKXAuy0KKjR4f2uSewoMsglAevo9nQaXwr9rx/Lh+K6DBJyIDVeKpw8mI+MoOVMUVOl 0fYhHa5ixmqHIXhbISdwR62flcdTF7XWP5PHEYGfEwXufLrPDGBTtbTfqNIWeNzkrI/l hp2jnZNv9vrfIG8Ex8DlkVDJ17v1Y9TRhbzlgJApb8leorA4jappi9c1gX+U8yP67rmS ZqXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=aG/6VJAuRbFI92ikmGfoMv9gEFQfb1tWIpO7XSYMEwY=; b=SaROiaxFnnPHGGnyaZXHGf0BnU9faoqp0yWLRNJPFp1pLvWEcR3O00rNKxvryYSfnk iNZ8x00iy137wIDbctSaa7ph1iGj5OU9/KSKWbzBV0pFc19G6op5f9VlFw3el/IWadOo AMya0tAKr7zGeB8esRjNRxOv9P0Jne/wZvJqqur1M6MGH4bH/AWmNEloGqjKf5TscV3a XwfSL+Emuo3HptpjXQrDp5CxRsrKKwhonVhKecphq3l64QH2O2zDi8ZVnZJJFTi9fqnY jLS+vlVgTfe6NkaJSXVV9yalzE0S7nyMt+up0K/EbOXLYdAfln00ttj8NaubH0cRtLZr bixA== X-Gm-Message-State: APjAAAVOKbSeewhPQKPKa9zqkTRadYt806FjrA3lEifjljwf36b+lmsJ 4suN8uEauJO0Z6QJsoxipAmmrQG7C0c= X-Received: by 2002:a1c:4d18:: with SMTP id o24mr19415804wmh.35.1576896186435; Fri, 20 Dec 2019 18:43:06 -0800 (PST) Received: from macbook.local ([212.45.67.2]) by smtp.googlemail.com with ESMTPSA id a133sm11749722wme.29.2019.12.20.18.43.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Dec 2019 18:43:05 -0800 (PST) Subject: Re: [PATCH] interconnect: Check for valid path in icc_set_bw() To: Bjorn Andersson Cc: linux-pm@vger.kernel.org, evgreen@chromium.org, daidavid1@codeaurora.org, okukatla@codeaurora.org, jcrouse@codeaurora.org, linux-kernel@vger.kernel.org References: <20191220171310.24169-1-georgi.djakov@linaro.org> <20191220190426.GE549437@yoga> From: Georgi Djakov Message-ID: <6a9d1b18-b34a-6ecb-0fe6-66dd7ee8cb52@linaro.org> Date: Sat, 21 Dec 2019 04:43:04 +0200 MIME-Version: 1.0 In-Reply-To: <20191220190426.GE549437@yoga> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Bjorn, Thanks for the comments! On 20.12.19 21:04, Bjorn Andersson wrote: > On Fri 20 Dec 09:13 PST 2019, Georgi Djakov wrote: > >> Use IS_ERR() to ensure that the path passed to icc_set_bw() is valid. >> >> Signed-off-by: Georgi Djakov >> --- >> drivers/interconnect/core.c | 5 +++++ >> 1 file changed, 5 insertions(+) >> >> diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c >> index 63c164264b73..14a6f7ade44a 100644 >> --- a/drivers/interconnect/core.c >> +++ b/drivers/interconnect/core.c >> @@ -498,6 +498,11 @@ int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw) >> if (!path || !path->num_nodes) >> return 0; >> >> + if (IS_ERR(path)) { > > This is a sign of a logical error, and the print is likely to be > ignored/lost in the noise. So I think the response should aid to help > the developer hitting this to resolve the issue. > > So I think this is more visible and more useful as: > > if (WARN_ON(IS_ERR(path))) > return -EINVAL; That's actually what i had in mind initially, but then started wondering whether this isn't a bit too noisy. But oh well, let's scream loud if something is done incorrectly. > > PS. Doesn't path->num_nodes == 0 fall in this category as well? When > would you have a path object with no nodes passed to this function? Yes, will make the warning cover this case too. Thanks, Georgi > > Regards, > Bjorn > >> + pr_err("%s: invalid path=%ld\n", __func__, PTR_ERR(path)); >> + return -EINVAL; >> + } >> + >> mutex_lock(&icc_lock); >> >> old_avg = path->reqs[0].avg_bw;