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: 164848 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1065043ili; Wed, 22 May 2019 09:25:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqwXtoqvIaUbaH1wZWmtoWSt+0pDfOlaCyUTj7qWKQ5+ve/fKOmBdqvovIiijRPGjt+Cjuww X-Received: by 2002:a62:2fc6:: with SMTP id v189mr59331658pfv.136.1558542322179; Wed, 22 May 2019 09:25:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558542322; cv=none; d=google.com; s=arc-20160816; b=DSsxxl1Xd2OnaCRK/N+FCy1G0ChihQUhN6DNdUPc933f/9ix5MAfT7V4RW1FauJVSS NwWXncaCJmXH4po4gQtxhnSvlt73j247yuMRF05SS3fxTMDG1NUvu44/31cEFNkcCC3M zxBw5ZDYrXxWoYnuDK7rgLMiAjJTfsdYGFQDPZ9Kx+HVaiNjlf6yhHUAEO50R3Zf5pw2 EcYirCFYUfDa7w7cLcwTPZ7xs4YF1YRcdK0YLHCjU0NcYvuQq6EZz9deZOW3+gKc3XVF hS+kKImjTw9lt4XDU003WJwtHq7oeU48ms6hPedZcHtEbnXViU+uIW4ADL160cvOVxGe oezA== 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=OWGOVdMecY70uPThuN9Z8RHD52HpQ5FIVR/nn5jAdfI=; b=jhTBRtYLJ2kKXE5cebvPPMbFZPGD6/nfxhUqIEXErGwZMui/D7sgaDYS+SKHqDYIlU ZsLy/DmtgVu4cPR4MzS60vIayHNx/2rbDXdDsf2qKY9UvoDdlA7vdwccjbJIypH/o/g9 KvGIv3fIeLqDSOP5cPN1J/ydaNSfWHm/rFdMrkrc+j7NTWbxJNrZL+i+e1jGGPUcQJSW LsFoB4y8vUqIHZ4mRc0s1RnZfcS6Tb259kQa05vRD716UaonRu4dAZuftBidY9qYmf2g 9kyGdDzezWU7ZxRvTUGcyPjVXZFWXQoAc+eO5vPZHdZVYAqE1nAJR0mY/SyDWFRArRgE 00UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vmezZTYs; 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 q23si26482899pfh.28.2019.05.22.09.25.21; Wed, 22 May 2019 09:25:22 -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=@linaro.org header.s=google header.b=vmezZTYs; 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 S1730033AbfEVQZU (ORCPT + 30 others); Wed, 22 May 2019 12:25:20 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:39730 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729475AbfEVQZU (ORCPT ); Wed, 22 May 2019 12:25:20 -0400 Received: by mail-wm1-f65.google.com with SMTP id n25so2857854wmk.4 for ; Wed, 22 May 2019 09:25:19 -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=Kb6Yl1hdxlUKwkY/9nFFu2K5mAM4s/O7Qqw2mGfMOgTMUKm+D3CTvT3se8+WfRLf4/ n4p5gISiFPhQStkiHyjZNrRx0xeDL9V1dm85/WDW1OviPCGnJfyxBSGa68fz5DXs0L8L BFdkHhmDFUCsTf0MbBSw1kKzmpvkDi7jlsUFkMcNj/6LZIzxlNsZzkLPE4Xpq7wFiqsw sl6DNnPG3mxoZWrTJM6dCGVDQGDf7jsUvhj/vktbSeon76f46OMAiln6UuIlj0fRTNSK L1mblqCieKfSkoDHedkWhy+ryDa+Wc6oAzEaxVuBBJhQZfGVXiuIYVucbYmWzuM6Kfrm toBg== X-Gm-Message-State: APjAAAUIzhi0SRiAlvEuXJ3QkYOXDiGZq0q2xYSyayhghCjY+ka1KdOr 0+JGOM8/rAmN3k9YQDfua/BtwA== 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 Cc: sanyog.r.kale@intel.com, pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH] soundwire: stream: fix out of boundary access on port properties 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/soundwire/stream.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) -- 2.21.0 Acked-by: Pierre-Louis Bossart 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]; }