devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sumit Gupta <sumitg@nvidia.com>
To: Lorenzo Pieralisi <lpieralisi@kernel.org>
Cc: <treding@nvidia.com>, <krzysztof.kozlowski@linaro.org>,
	<dmitry.osipenko@collabora.com>, <viresh.kumar@linaro.org>,
	<rafael@kernel.org>, <jonathanh@nvidia.com>, <robh+dt@kernel.org>,
	<helgaas@kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-tegra@vger.kernel.org>, <linux-pm@vger.kernel.org>,
	<devicetree@vger.kernel.org>, <linux-pci@vger.kernel.org>,
	<mmaddireddy@nvidia.com>, <kw@linux.com>, <bhelgaas@google.com>,
	<vidyas@nvidia.com>, <sanjayc@nvidia.com>,
	<ksitaraman@nvidia.com>, <ishah@nvidia.com>, <bbasu@nvidia.com>,
	Sumit Gupta <sumitg@nvidia.com>
Subject: Re: [Patch v6 7/9] PCI: tegra194: Fix possible array out of bounds access
Date: Mon, 24 Apr 2023 18:33:38 +0530	[thread overview]
Message-ID: <c247a72c-5e69-09ed-e7a6-c87a410f392c@nvidia.com> (raw)
In-Reply-To: <ZEKL1XzYzOwcEkHK@lpieralisi>



On 21/04/23 18:42, Lorenzo Pieralisi wrote:
> External email: Use caution opening links or attachments
> 
> 
> On Tue, Apr 11, 2023 at 04:30:00PM +0530, Sumit Gupta wrote:
>> Add check to fix the possible array out of bounds violation by
>> making speed equal to GEN1_CORE_CLK_FREQ when its value is more
>> than the size of "pcie_gen_freq" array. This array has size of
>> four but possible speed (CLS) values are from "0 to 0xF". So,
>> "speed - 1" values are "-1 to 0xE". This change was suggested by
>> "Bjorn Helgaas" in the below link.
> 
> There is a Suggested-by tag and a Link: tag remove the last
> sentence, that's duplicate information.
> 
Removed in v7.

Thank you,
Sumit Gupta

>> Suggested-by: Bjorn Helgaas <helgaas@kernel.org>
>> Signed-off-by: Sumit Gupta <sumitg@nvidia.com>
>> Link: https://lore.kernel.org/lkml/72b9168b-d4d6-4312-32ea-69358df2f2d0@nvidia.com/
>> ---
>>   drivers/pci/controller/dwc/pcie-tegra194.c | 13 +++++++++++--
>>   1 file changed, 11 insertions(+), 2 deletions(-)
> 
> Acked-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
> 
>> diff --git a/drivers/pci/controller/dwc/pcie-tegra194.c b/drivers/pci/controller/dwc/pcie-tegra194.c
>> index 09825b4a075e..e6eec85480ca 100644
>> --- a/drivers/pci/controller/dwc/pcie-tegra194.c
>> +++ b/drivers/pci/controller/dwc/pcie-tegra194.c
>> @@ -223,6 +223,7 @@
>>   #define EP_STATE_ENABLED     1
>>
>>   static const unsigned int pcie_gen_freq[] = {
>> +     GEN1_CORE_CLK_FREQ,     /* PCI_EXP_LNKSTA_CLS == 0; undefined */
>>        GEN1_CORE_CLK_FREQ,
>>        GEN2_CORE_CLK_FREQ,
>>        GEN3_CORE_CLK_FREQ,
>> @@ -459,7 +460,11 @@ static irqreturn_t tegra_pcie_ep_irq_thread(int irq, void *arg)
>>
>>        speed = dw_pcie_readw_dbi(pci, pcie->pcie_cap_base + PCI_EXP_LNKSTA) &
>>                PCI_EXP_LNKSTA_CLS;
>> -     clk_set_rate(pcie->core_clk, pcie_gen_freq[speed - 1]);
>> +
>> +     if (speed >= ARRAY_SIZE(pcie_gen_freq))
>> +             speed = 0;
>> +
>> +     clk_set_rate(pcie->core_clk, pcie_gen_freq[speed]);
>>
>>        if (pcie->of_data->has_ltr_req_fix)
>>                return IRQ_HANDLED;
>> @@ -1020,7 +1025,11 @@ static int tegra_pcie_dw_start_link(struct dw_pcie *pci)
>>
>>        speed = dw_pcie_readw_dbi(pci, pcie->pcie_cap_base + PCI_EXP_LNKSTA) &
>>                PCI_EXP_LNKSTA_CLS;
>> -     clk_set_rate(pcie->core_clk, pcie_gen_freq[speed - 1]);
>> +
>> +     if (speed >= ARRAY_SIZE(pcie_gen_freq))
>> +             speed = 0;
>> +
>> +     clk_set_rate(pcie->core_clk, pcie_gen_freq[speed]);
>>
>>        tegra_pcie_enable_interrupts(pp);
>>
>> --
>> 2.17.1
>>

  reply	other threads:[~2023-04-24 13:04 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-11 10:59 [Patch v6 0/9] Tegra234 Memory interconnect support Sumit Gupta
2023-04-11 10:59 ` [Patch v6 1/9] memory: tegra: add interconnect support for DRAM scaling in Tegra234 Sumit Gupta
2023-04-11 10:59 ` [Patch v6 2/9] memory: tegra: add mc clients for Tegra234 Sumit Gupta
2023-04-11 10:59 ` [Patch v6 3/9] memory: tegra: add software mc clients in Tegra234 Sumit Gupta
2023-04-11 10:59 ` [Patch v6 4/9] dt-bindings: tegra: add icc ids for dummy MC clients Sumit Gupta
2023-04-11 10:59 ` [Patch v6 5/9] memory: tegra: make cpu cluster bw request a multiple of mc channels Sumit Gupta
2023-04-11 10:59 ` [Patch v6 6/9] cpufreq: tegra194: add OPP support and set bandwidth Sumit Gupta
2023-04-18  9:13   ` Viresh Kumar
2023-04-18 10:21     ` Sumit Gupta
2023-04-18 10:38   ` Viresh Kumar
2023-04-11 11:00 ` [Patch v6 7/9] PCI: tegra194: Fix possible array out of bounds access Sumit Gupta
2023-04-21 13:12   ` Lorenzo Pieralisi
2023-04-24 13:03     ` Sumit Gupta [this message]
2023-04-11 11:00 ` [Patch v6 8/9] PCI: tegra194: Add interconnect support in Tegra234 Sumit Gupta
2023-04-13 14:52   ` Lorenzo Pieralisi
2023-04-14 10:54     ` Sumit Gupta
2023-04-21 13:11       ` Lorenzo Pieralisi
2023-04-24 13:02         ` Sumit Gupta
2023-04-11 11:00 ` [Patch v6 9/9] arm64: tegra: Add cpu OPP tables and interconnects property Sumit Gupta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c247a72c-5e69-09ed-e7a6-c87a410f392c@nvidia.com \
    --to=sumitg@nvidia.com \
    --cc=bbasu@nvidia.com \
    --cc=bhelgaas@google.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.osipenko@collabora.com \
    --cc=helgaas@kernel.org \
    --cc=ishah@nvidia.com \
    --cc=jonathanh@nvidia.com \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=ksitaraman@nvidia.com \
    --cc=kw@linux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=mmaddireddy@nvidia.com \
    --cc=rafael@kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=sanjayc@nvidia.com \
    --cc=treding@nvidia.com \
    --cc=vidyas@nvidia.com \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).