Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1052838pxv; Thu, 22 Jul 2021 21:00:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRtAmso/pWBOLDA1rGfmGfcwG30ZbjslpCGCj2o/DJuLy+hgA1yOU8N0mSP6g4OCHekS89 X-Received: by 2002:aa7:dc55:: with SMTP id g21mr3338196edu.129.1627012820266; Thu, 22 Jul 2021 21:00:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627012820; cv=none; d=google.com; s=arc-20160816; b=ZcQkz9TqC4gN8QMT+/Ka/pW3mwyo9LIVORyJMV1Whvd86oV9YLltAD/ZwN7vv0gn30 5JiVK3CFLW4PmNfL4AGGR14jZTI3CSRsE9xsr4OK3aUuZ6OTQKCzymg7EBn1s9IyBITk ucV7r2KfiiLbS3ZiY5W/ld08NY7qqB7CQBCy68vrddvf7ms6VSEIIxXizMe/z8598OXA t9QAOsz73YMyC15ap7n6uydeVL13DrENvriYhTA+jmQNZj1ytjZMOm9rZEKbJyzCtr3l xbvsWbtsjST/Dgsckv0yYRTUYgfqb6Ce+cRqvgJRgE0LiuLhybJp/gMWBZxxs5oV/O0G scng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=p4sgRsAHDz7z4nN8OhXVXJqeztEsM8kJQV51Q4Is4h0=; b=xOruax/RjfMpnjXegWMMtWFzXDsf/2r16BhfCkzWsn3fomxIb9eJtw1N88nYm+kcRh oqqK2HLtcGJtrgt2qJU/83udrBLsf+Jb4YmVDtuq+lt7Rj1XBK0PGG+LF2mhypZKPNhX 7vIBngDe8sBerGmdxBZ4g6/vtg9H3CLUTiDqz7m+0XY5y428aJ87nDrGvzdU+m3Quh54 JR3QNkQrESSfKXvK4tzQ2AB0EGCw12cekgIpEugWJ401pBa5rpsk+D1UbwDzn66tjlUU xhsshFMUnBVLxDRL0z8Jwdl5pQXhTcMBc7PT+qEs23BjbyFKcOECN/tDhNNNu1qKfhJ6 D97w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VPxjsF1v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s20si29901624edr.223.2021.07.22.20.59.52; Thu, 22 Jul 2021 21:00:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VPxjsF1v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233934AbhGWDR0 (ORCPT + 99 others); Thu, 22 Jul 2021 23:17:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:37292 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233642AbhGWDRI (ORCPT ); Thu, 22 Jul 2021 23:17:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BECB460EC0; Fri, 23 Jul 2021 03:57:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627012662; bh=uIO2cszPdhBYJGfbs19fiW03dSSWxLg/CsSfze1N1yU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VPxjsF1vcccZIrCQFb6Y7egxFFz/WIvBMprja9bqqZS/WVFTuDiygzxhUdN9ek03O izugaPgAg985K7si2P3DMyUKzmQtBjTdvCilxfESwyriqq6eqT2aJ50taQ4A53UtMt CgKG5cQbIU1d2JZ4HMjPPFpc3i9I6nQiWBRCpTOKL8Ik/7hqXnCaynEmJDF/hSDFB5 loAZ1W9vwKwp2NpkUxAR2pHxm0JxyGPp0TEEPmP12ch4n/flF0eF/2SiWG8f2FdL9C 35Rmared8PiJNoJDxUthmu8Ohh/3vzE5HzcaS3K+Dd0vJ9z7wnBNkF9Ie7ssJWTpZc BO3d8yf50YQxQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Cristian Marussi , Vincent Guittot , Sudeep Holla , Sasha Levin , linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 5.13 15/19] firmware: arm_scmi: Fix range check for the maximum number of pending messages Date: Thu, 22 Jul 2021 23:57:16 -0400 Message-Id: <20210723035721.531372-15-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210723035721.531372-1-sashal@kernel.org> References: <20210723035721.531372-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Cristian Marussi [ Upstream commit bdb8742dc6f7c599c3d61959234fe4c23638727b ] SCMI message headers carry a sequence number and such field is sized to allow for MSG_TOKEN_MAX distinct numbers; moreover zero is not really an acceptable maximum number of pending in-flight messages. Fix accordingly the checks performed on the value exported by transports in scmi_desc.max_msg Link: https://lore.kernel.org/r/20210712141833.6628-3-cristian.marussi@arm.com Reported-by: Vincent Guittot Signed-off-by: Cristian Marussi [sudeep.holla: updated the patch title and error message] Signed-off-by: Sudeep Holla Signed-off-by: Sasha Levin --- drivers/firmware/arm_scmi/driver.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index ce81ed053876..b342490e032b 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -1022,8 +1022,9 @@ static int __scmi_xfer_info_init(struct scmi_info *sinfo, const struct scmi_desc *desc = sinfo->desc; /* Pre-allocated messages, no more than what hdr.seq can support */ - if (WARN_ON(desc->max_msg >= MSG_TOKEN_MAX)) { - dev_err(dev, "Maximum message of %d exceeds supported %ld\n", + if (WARN_ON(!desc->max_msg || desc->max_msg > MSG_TOKEN_MAX)) { + dev_err(dev, + "Invalid maximum messages %d, not in range [1 - %lu]\n", desc->max_msg, MSG_TOKEN_MAX); return -EINVAL; } -- 2.30.2