Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4488351rwb; Tue, 6 Sep 2022 08:12:01 -0700 (PDT) X-Google-Smtp-Source: AA6agR5EobmDoZj+5PigRmTqcbJGpxVFUFDo7+6JlvLctfddwjocFlz1Wvymw+FA7g9haw92xZmc X-Received: by 2002:a17:906:58cf:b0:750:524b:e694 with SMTP id e15-20020a17090658cf00b00750524be694mr14880692ejs.472.1662477120899; Tue, 06 Sep 2022 08:12:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662477120; cv=none; d=google.com; s=arc-20160816; b=reeXsGUuEJ702f+xoH61wkPOtbiMI9noxkcwU+BnNdruOQ3wwUwiot1uwodPMmz7Rp 5Hz51MnObRTBQAnnDMC9A/wKsqPsnoDzkB2Yru2fo3lNtAPggHGBcqzRoZIUNb5xMMJf MS9CWPDX6+eqRSpEz8wyNtkowSfeMB40IaPI7PN3c8dF/PVSZy5ekDvuedwifhZUnzFX PjF5phvnEYbdpCqLX0uUUXN1n4CI8aa819L/QMXmuBM/RIIXw6uKYiqHddcKQZz2wr1m ORp2QaIJoS2YGRqNp+d0Jb0hOWl5jJnyCYB9I+VV0NjOmd/losJ0kgpSvB0+XgY2fNLp HJMw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RRJJ4k5cBqRxw66V7AAeOM27INtFoTf7qAI2WVc0Xoo=; b=iW8uRePK0elQDYBKF7upsfhju1VLkywqZZ5OtA+6sftO/rGdupo2reQ1NtAhD/TSCT 3a5X9VQc4UljWCxlLDHSYL2kDL9pE7GLj4fFCuFTdb8nnNNX8DKMEpbFO2Y6MxwDxBT3 YlbAv9wBFczA1BetprKy+ptCDxoeWoQB1ZmsBPdu5mh3Ft9mOWII6spynGUuCeWDviJ1 ydB4OTRGXqUj27ITmOJfeMHs7yr/F5PgOBo+wCe++5v6AsZyQrByYBsSlobAvj+iBU+Q WmjsVzbRJ/9pMM/yF9zczUFrmdYmengb1EY+LMX2OgWOn3SAqjZsikOzvb6a1lANFtQ8 gt0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=i1gvUVwZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dp19-20020a170906c15300b0076ef29f5a93si2493041ejc.697.2022.09.06.08.11.34; Tue, 06 Sep 2022 08:12:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=i1gvUVwZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239904AbiIFOFr (ORCPT + 99 others); Tue, 6 Sep 2022 10:05:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241423AbiIFOET (ORCPT ); Tue, 6 Sep 2022 10:04:19 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54F8623BEA; Tue, 6 Sep 2022 06:44:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 64FEACE1787; Tue, 6 Sep 2022 13:43:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5322FC433D6; Tue, 6 Sep 2022 13:43:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662471827; bh=3hpdQp57BRCXBbsCxXizJ7fG6VM4WmSuuLi+zKB2HRA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i1gvUVwZL31p9V9no9DTRXnWpZ7fVzXf4gHrtdRDOyGVP3vGCbwtzNEmBFSxAbjU0 JNz5ENx7O7SoiO0zSXYR1fRZJHtOW77YgkpksO8OeUIZEifuRNlhm6M6pRmTujdv3F hCRRFCwAaDpMhglrfktqBjp4sAlI6ez2xlnOGtSk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Srinivas Kandagatla , Vinod Koul , Sasha Levin Subject: [PATCH 5.19 052/155] soundwire: qcom: fix device status array range Date: Tue, 6 Sep 2022 15:30:00 +0200 Message-Id: <20220906132831.621159459@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220906132829.417117002@linuxfoundation.org> References: <20220906132829.417117002@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Srinivas Kandagatla [ Upstream commit 4ef3f2aff1267bfa6d5a90c42a30b927b8aa239b ] This patch updates device status array range from 11 to 12 as we will be reading status from device number 0 to device number 11 inclusive. Without this patch we can potentially access status array out of range during auto-enumeration. Fixes: aa1262ca6695 ("soundwire: qcom: Check device status before reading devid") Reported-by: Dan Carpenter Signed-off-by: Srinivas Kandagatla Link: https://lore.kernel.org/r/20220708104747.8722-1-srinivas.kandagatla@linaro.org Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/soundwire/qcom.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c index b5ec7726592c8..71d2931cb885c 100644 --- a/drivers/soundwire/qcom.c +++ b/drivers/soundwire/qcom.c @@ -167,7 +167,7 @@ struct qcom_swrm_ctrl { u8 wcmd_id; struct qcom_swrm_port_config pconfig[QCOM_SDW_MAX_PORTS]; struct sdw_stream_runtime *sruntime[SWRM_MAX_DAIS]; - enum sdw_slave_status status[SDW_MAX_DEVICES]; + enum sdw_slave_status status[SDW_MAX_DEVICES + 1]; int (*reg_read)(struct qcom_swrm_ctrl *ctrl, int reg, u32 *val); int (*reg_write)(struct qcom_swrm_ctrl *ctrl, int reg, int val); u32 slave_status; @@ -411,7 +411,7 @@ static int qcom_swrm_get_alert_slave_dev_num(struct qcom_swrm_ctrl *ctrl) ctrl->reg_read(ctrl, SWRM_MCP_SLV_STATUS, &val); - for (dev_num = 0; dev_num < SDW_MAX_DEVICES; dev_num++) { + for (dev_num = 0; dev_num <= SDW_MAX_DEVICES; dev_num++) { status = (val >> (dev_num * SWRM_MCP_SLV_STATUS_SZ)); if ((status & SWRM_MCP_SLV_STATUS_MASK) == SDW_SLAVE_ALERT) { @@ -431,7 +431,7 @@ static void qcom_swrm_get_device_status(struct qcom_swrm_ctrl *ctrl) ctrl->reg_read(ctrl, SWRM_MCP_SLV_STATUS, &val); ctrl->slave_status = val; - for (i = 0; i < SDW_MAX_DEVICES; i++) { + for (i = 0; i <= SDW_MAX_DEVICES; i++) { u32 s; s = (val >> (i * 2)); -- 2.35.1