From patchwork Wed May 22 16:24:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 10956331 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2A0F16C5 for ; Wed, 22 May 2019 16:32:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19ACC28708 for ; Wed, 22 May 2019 16:32:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DC3A28C74; Wed, 22 May 2019 16:32:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2D0FD28708 for ; Wed, 22 May 2019 16:31:59 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 76669168D; Wed, 22 May 2019 18:31:07 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 76669168D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1558542717; bh=QE8IoMJnMrQcbJls1dhl05z59v5eNU3nOhHTfNBHmHM=; h=From:To:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=DBLPNjprvGela4EO6Yr7OIbNb8D+jhY5MSUtBuMPc0Hn04+zonSJWe6IhHpiIlg/9 2rnQM2HQ7qM7wjAeszKajx4mRMZKEgOtP2BN/Tv8WLOzNkE4X8TEqTgg34PZXMaLQf soxtt4/GTw54Zm5Z/m3HRxJYxoZ0Gudw4KeaRAHc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id EAAB4F8962C; Wed, 22 May 2019 18:25:22 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id C4A22F89630; Wed, 22 May 2019 18:25:21 +0200 (CEST) Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 45AABF89625 for ; Wed, 22 May 2019 18:25:18 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 45AABF89625 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="vmezZTYs" Received: by mail-wm1-x342.google.com with SMTP id j187so2874436wmj.1 for ; Wed, 22 May 2019 09:25:18 -0700 (PDT) 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=OWGOVdMecY70uPThuN9Z8RHD52HpQ5FIVR/nn5jAdfI=; b=vmezZTYs//lLcUcn9Z2DSFVgsemU319BFV8a/+s4QFULfj+oV1MkrsVnARJSVUcyn7 2I+wVuPvs2tzsECElLxCGkqQzkEqht1LnNWCseU2XQt1puHVkJnfN0pagtJLjeV+JiZS w7/AoGnhzoewNRIHjyHsiSGerFiIqHMxJUr9O53Yhn5RrZSBVe+rJhktHXli/9xmjrE4 nAve702w/sZnEWEb7+6h6AZX5/2M136TSuszdl9VG9aHweEnp1ii2wsJ3PHq3iLN5ZpZ MCYZYvdJB2SLROSmcFAqJfskNvtQzLsRVIx62tE73OuP+POEIfb6yfrK30MFGOyNliXl zj9A== 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=OWGOVdMecY70uPThuN9Z8RHD52HpQ5FIVR/nn5jAdfI=; b=pdPYxj+zg2eq++WUgLuR3vjcdBpGs04LV9p0HF0KMw4aovVenIpF9iS+NjCkAi/FRq Wn1e4xH1aN/PXwQMviKMMHtK6vrI3qPMy4cqBXqprNo/qs/5MqzwFRz1KsxIKwFx8oac idjAJ55dKVoltebAD5uT+qAYfvXdiE7Bx/+Zaxsmgfe2Vo6vBY1YwE8xrbVfxIlT6PV5 t0O423K/HanyzcajeXiX48+One4OmyBp1aFgdUBFpnQlGtTBp7t57KrXShgZiP9M7Z8W N2yvpcqVH24ktFwmEOrYw4ws3JOQIs2P22C6CMRa6Olhr//OfNlWckdOVQT4mDwj3Yk9 w3Zw== X-Gm-Message-State: APjAAAXm/syjVF+bKfgCRhUKIuU9lobvGq+P+cMObd50tVmivRg4m55Z jlZhPHy3E97FDcyl23cAbtoVwCnkiBo/Uw== X-Google-Smtp-Source: APXvYqx3cV+KcaZgMn/uTRwxQMjy04ngPuH6R/wzSryVgaFWXel2dzT3vOZoSzw8BdI52xi8p/n+gQ== X-Received: by 2002:a1c:6a08:: with SMTP id f8mr8032679wmc.81.1558542318259; Wed, 22 May 2019 09:25:18 -0700 (PDT) Received: from srini-hackbox.lan (cpc89974-aztw32-2-0-cust43.18-1.cable.virginm.net. [86.30.250.44]) by smtp.gmail.com with ESMTPSA id c14sm20390656wrt.45.2019.05.22.09.25.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 May 2019 09:25:17 -0700 (PDT) From: Srinivas Kandagatla To: vkoul@kernel.org Date: Wed, 22 May 2019 17:24:43 +0100 Message-Id: <20190522162443.5780-1-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Cc: sanyog.r.kale@intel.com, Srinivas Kandagatla , pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [alsa-devel] [PATCH] soundwire: stream: fix out of boundary access on port properties X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP Assigning local iterator to array element and using it again for indexing would cross the array boundary. Fix this by directly referring array element without using the local variable. Signed-off-by: Srinivas Kandagatla Acked-by: Pierre-Louis Bossart --- drivers/soundwire/stream.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c index d01060dbee96..544925ff0b40 100644 --- a/drivers/soundwire/stream.c +++ b/drivers/soundwire/stream.c @@ -1406,9 +1406,7 @@ struct sdw_dpn_prop *sdw_get_slave_dpn_prop(struct sdw_slave *slave, } for (i = 0; i < num_ports; i++) { - dpn_prop = &dpn_prop[i]; - - if (dpn_prop->num == port_num) + if (dpn_prop[i].num == port_num) return &dpn_prop[i]; }