Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3928572imm; Mon, 8 Oct 2018 11:50:41 -0700 (PDT) X-Google-Smtp-Source: ACcGV62R3jvmfOvH590srNfS34mBVUhfZ1Eb1+tgVDO+P3mMTOW8Vyn48BwgeZUPOFknptnmZWvy X-Received: by 2002:a62:509a:: with SMTP id g26-v6mr26036979pfj.62.1539024641524; Mon, 08 Oct 2018 11:50:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539024641; cv=none; d=google.com; s=arc-20160816; b=pVkKXstFnIxnVLB3THy3vxwnU+wEBS+RyLK7cPrNImumjiatZeAVEj7oQfg8FConKS A4k9yPy9p0G9XIDGDnmXObDqCOohImZWgbMHtD1cIouEpjZNaE02kMGmy83j2O2musA9 PSX7bLtAbTFZxtbwTie8mbsxGPIiS7yWbVbj9e9Cl9cvrajMgBOL1rGFCfLsxig23UAx 89+5NCQ7BJNd6N3in+LeuhQbb7b9YqwFiWdKCi3Q6xLDXaf4kx+toAsA/0gK40Yh+KnQ +/TQVjiwCp/KhCw/NKZQYMV1pNTr9nfBlXZBf+Zzs5KbeCqCeEj2a/qN2+j7emZPAO8l XCgg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yYmoZ6fDoehg1sCkOuyZLkSjthBxliZUFqbHjSoXNu0=; b=d++Wn1g8DR4RW4gOPivutitw3Na7Hkhfs6OVPxGEXxkv+Pslcqu8FAR9r3+o5gjSRH yYgysxHyiGncPIMQjKGIReTxQS/rKurnZn0dr11z6d51u96N5ByQZxVua82NLCBAyyKH QHOM22Z9yWsu3l5+GlBRe49K7oTU8eEBlwJvkC4BCxuv7Nmij+N1lLUQZkH1GZVgfMcS BwvRvJnzc7jlaMSAuOvWsV4apTIGFzyCE1X0edoJhnaPWCt9CxMgSssoEAW4EPNNasXj UQpfMQhBO0iH0qjN+QofoFwPHagyPEdqrYTZ3nsGr72LSHcEFtW5yTVOD5Q0cZ/MfufW SBpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JwdCUT0K; 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 k135-v6si20765112pfd.168.2018.10.08.11.50.26; Mon, 08 Oct 2018 11:50:41 -0700 (PDT) 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=@kernel.org header.s=default header.b=JwdCUT0K; 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 S1731794AbeJICCM (ORCPT + 99 others); Mon, 8 Oct 2018 22:02:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:51426 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726991AbeJICCM (ORCPT ); Mon, 8 Oct 2018 22:02:12 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2F28321508; Mon, 8 Oct 2018 18:49:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539024545; bh=zu3NtjZLN/NzA2S/Lyal5ImadyqG8QwsFt3nX47odjU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JwdCUT0KWcQ30JmYRReI8OG+28VUXh9mD5YOaJfAypGgN3pzZ5/xs2dKvz0o/msFD WTUKfgcu+JMPpRvArjneR3/0v7ez9S0dL6nOyPSlqfkDkvBeRC8ivEQHBQhZBG9JyT h7SUgRpBTEFuu8P6fKPVO16MhRBNHZCtR+ey4/Cc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ionela Voinescu , Sudeep Holla , Olof Johansson , Sasha Levin Subject: [PATCH 4.18 075/168] firmware: arm_scmi: fix divide by zero when sustained_perf_level is zero Date: Mon, 8 Oct 2018 20:30:55 +0200 Message-Id: <20181008175622.924936054@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181008175620.043587728@linuxfoundation.org> References: <20181008175620.043587728@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sudeep Holla [ Upstream commit 96d529bac562574600eda85726fcfa3eef6dde8e ] Firmware can provide zero as values for sustained performance level and corresponding sustained frequency in kHz in order to hide the actual frequencies and provide only abstract values. It may endup with divide by zero scenario resulting in kernel panic. Let's set the multiplication factor to one if either one or both of them (sustained_perf_level and sustained_freq) are set to zero. Fixes: a9e3fbfaa0ff ("firmware: arm_scmi: add initial support for performance protocol") Reported-by: Ionela Voinescu Signed-off-by: Sudeep Holla Signed-off-by: Olof Johansson Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/arm_scmi/perf.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/drivers/firmware/arm_scmi/perf.c +++ b/drivers/firmware/arm_scmi/perf.c @@ -166,7 +166,13 @@ scmi_perf_domain_attributes_get(const st le32_to_cpu(attr->sustained_freq_khz); dom_info->sustained_perf_level = le32_to_cpu(attr->sustained_perf_level); - dom_info->mult_factor = (dom_info->sustained_freq_khz * 1000) / + if (!dom_info->sustained_freq_khz || + !dom_info->sustained_perf_level) + /* CPUFreq converts to kHz, hence default 1000 */ + dom_info->mult_factor = 1000; + else + dom_info->mult_factor = + (dom_info->sustained_freq_khz * 1000) / dom_info->sustained_perf_level; memcpy(dom_info->name, attr->name, SCMI_MAX_STR_SIZE); }