Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp21699294ybl; Mon, 6 Jan 2020 09:28:47 -0800 (PST) X-Google-Smtp-Source: APXvYqwKzQrF+agNR8grwXJqcyhT3+UBkxOk+8lCiqSmTnkiw2YxoODFS0eitIwT2P6lSF+uafJr X-Received: by 2002:a9d:7852:: with SMTP id c18mr105914367otm.247.1578331727654; Mon, 06 Jan 2020 09:28:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578331727; cv=none; d=google.com; s=arc-20160816; b=n1d9F/DhkyV21tw+sJyP6Sd6ZRglsA3avnicuy/C/I6vWyqNHD+BxmJO2G5fuL4iwa MjSsrY6/1pPmvs3j55u+98EDKtsOgcKgfnEVmWLp5VTFRlvk72sf3mSGXYIsbxfqphHA NKaznnGEDNvxxVfgyHpALa3kCrTMF2UW7S2HJsLAH7SeDnAyMELl3ZzLW9Mf3v/1b9lk In/OUAb4nAhOvQDy9fvDbym86+hLCU2eKoqbn7o7CEwj88oeydxrbJpZEPRU/vuqHLuX cS58b+Yml1TP3Kc59xMzYZdOVFcpkTVQjLbLspTk7sdezFybCAyhxr2wVFQSKU8NrFc6 zMSQ== 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:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=eA5OqXkB3++UqCw3nWhtcdXsiHuPwWe3zZsMrY+R6g0=; b=Z+wd4BKtK3y4CLExK8ITdlR2oujKIk5P+CNX/SCbyk31hTOug0pKcKaExE+cw0djKh k/wEeq9ZDrshaNqlHwFzvlxPE6TCBO8h9jVf+Srw3q/snIHsYdSDYiRKS8bF7x5GHHTJ FxamhzLyYrkOUDAdJ+/9d/LyGNQE+CAdrxbPounUr08lPbP73o2axrJcGI4x8ev+xSXx 88Hx/ps3MFRYx6jpmdF62+0eqvlrNSf+PCn/OaeJwSWrTOdXBdAyw/6d+ocDpwnYubrG jNl2prWct8LD7/E+MZrLVC2+tNS0aKjDnlM1skIhrLI8bpOURmSHMnsPOBLq/1jXjLVA nzOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jzpuGAHB; 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 l26si34801025oti.152.2020.01.06.09.28.34; Mon, 06 Jan 2020 09:28:47 -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=jzpuGAHB; 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 S1726612AbgAFR1r (ORCPT + 99 others); Mon, 6 Jan 2020 12:27:47 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:43908 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726448AbgAFR1q (ORCPT ); Mon, 6 Jan 2020 12:27:46 -0500 Received: by mail-wr1-f68.google.com with SMTP id d16so50542723wre.10 for ; Mon, 06 Jan 2020 09:27:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=eA5OqXkB3++UqCw3nWhtcdXsiHuPwWe3zZsMrY+R6g0=; b=jzpuGAHB6DfsAm0+WuzL4ucBxTHVpKeYsWix/3HqlDl/edJ/k1pa7eKLvJPg1I9b5x /KRJ3qh4H/O+NGKjY/7bQM9LmELJTS3ZIIyxXp/lhVPeODk3JK5r3WQa91+3foXpUdLf kI+io8ZjBwrS6qmYGu5Bqw/fNNCwnnDauNCl5moVv8JmjzLmt0lza/L/gKo6PH/vk/0n FPpAwtDPxch0nChyvNUxMOR7KlcEcV6Y61WGG9mrzWa/Qib7Lm+OSwOGB+/atVUdA3F/ mmNtHZwldHU0b7JiBcme5V3ekCtC7hdEPmKxijaiYc5UheEkoqMMWgDLprFv0kjyHBpO Za2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=eA5OqXkB3++UqCw3nWhtcdXsiHuPwWe3zZsMrY+R6g0=; b=Mjn1sujIoOGdj3/2fdciW2UjsMbCsRfuvBpBSh2dxC0BrYIjaHtF4qCO8ohv6Q6LYB BnFufZkv7U0sRplqztTGwFLIIiL5IUUfMa0FIK4nyYtqUTdGAVm/WlQnyT3kXhijsCoY RnCY8ZD4inIQZDrrD5/h6Q1Tz3dB6lAvJ/O0zRB8vCHPi5VdTSQrRfrSAIdsAAhoeyuH 7zVTIyPObtVpiINHAGPdUOrJSuKHZ13ZX/T0jjUVYC68IV1zubpMpVF8CyKZ9O+S+Ti1 UIt+SWOwMw3gJwNfP6sMal8bvDosMsT3yjvItHLWWVGadNBe4RJg692dB8l2uLPJe2OD FDHg== X-Gm-Message-State: APjAAAUiDf56jrpHZ+qE5n6ddPHZdCs6bXpnAtOUYsCrkQpztqWWZg0w dTBpVmD0xsS6i4Rm0QvtmTvjYFBs86I= X-Received: by 2002:a05:6000:f:: with SMTP id h15mr98382623wrx.90.1578331664634; Mon, 06 Jan 2020 09:27:44 -0800 (PST) Received: from localhost.localdomain ([212.45.67.2]) by smtp.googlemail.com with ESMTPSA id z187sm23725757wme.16.2020.01.06.09.27.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 Jan 2020 09:27:44 -0800 (PST) From: Georgi Djakov To: linux-pm@vger.kernel.org Cc: bjorn.andersson@linaro.org, evgreen@chromium.org, daidavid1@codeaurora.org, okukatla@codeaurora.org, jcrouse@codeaurora.org, georgi.djakov@linaro.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] interconnect: Check for valid path in icc_set_bw() Date: Mon, 6 Jan 2020 19:27:46 +0200 Message-Id: <20200106172746.19803-1-georgi.djakov@linaro.org> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use IS_ERR() to ensure that the path passed to icc_set_bw() is valid. Signed-off-by: Georgi Djakov --- v2: - Use WARN_ON() instead of pr_err() (Bjorn) drivers/interconnect/core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c index 63c164264b73..d2ba5ae7d25b 100644 --- a/drivers/interconnect/core.c +++ b/drivers/interconnect/core.c @@ -495,9 +495,12 @@ int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw) size_t i; int ret; - if (!path || !path->num_nodes) + if (!path) return 0; + if (WARN_ON(IS_ERR(path) || !path->num_nodes)) + return -EINVAL; + mutex_lock(&icc_lock); old_avg = path->reqs[0].avg_bw;