mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
To: Jakub Kicinski <kuba@kernel.org>, konradybcio@kernel.org
Cc: netdev@vger.kernel.org, elder@riscstar.com, pabeni@redhat.com,
	andrew+netdev@lunn.ch, krzk@kernel.org,
	linux-kernel@vger.kernel.org, conor+dt@kernel.org,
	linux-arm-msm@vger.kernel.org, dmitry.baryshkov@oss.qualcomm.com,
	devicetree@vger.kernel.org, krzk+dt@kernel.org, robh@kernel.org,
	edumazet@google.com, elder@kernel.org, andersson@kernel.org,
	krzysztof.kozlowski@oss.qualcomm.com, davem@davemloft.net,
	marijn.suijten@somainline.org, horms@kernel.org
Subject: Re: [net-next,v5,3/3] net: ipa: Grab IMEM slice base/size from DTS
Date: Mon, 2 Mar 2026 15:03:04 +0100	[thread overview]
Message-ID: <35b72adc-8f67-4cd1-a210-8bc88af39a5a@oss.qualcomm.com> (raw)
In-Reply-To: <20260227015449.2484275-1-kuba@kernel.org>

On 2/27/26 2:54 AM, Jakub Kicinski wrote:
> This is an AI-generated review of your patch. The human sending this
> email has considered the AI review valid, or at least plausible.
> 
> For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
> ---

[...]

>> @@ -656,7 +659,24 @@ int ipa_mem_init(struct ipa *ipa, struct platform_device *pdev,
>>  	ipa->mem_addr = res->start;
>>  	ipa->mem_size = resource_size(res);
>>
>> -	ret = ipa_imem_init(ipa, mem_data->imem_addr, mem_data->imem_size);
>> +	ipa_slice_np = of_parse_phandle(dev->of_node, "sram", 0);
>> +	if (ipa_slice_np) {
>> +		ret = of_address_to_resource(ipa_slice_np, 0, res);
>> +		of_node_put(ipa_slice_np);
>> +		if (ret)
>> +			goto err_unmap;
>> +
>> +		imem_base = res->start;
>> +		imem_size = resource_size(res);
>                      ^^^^
> 
> Does this code corrupt the platform device's resource array? The variable
> 'res' was obtained from platform_get_resource_byname() earlier in this
> function, which returns a pointer directly into pdev->resource[]:
> 
> drivers/base/platform.c:platform_get_resource_byname()
>     return platform_get_resource(dev, type, num);
>         => return &dev->resource[i];
> 
> Passing this pointer to of_address_to_resource() causes
> __of_address_to_resource() to memset the entire structure to zero and then
> overwrite all fields:
> 
> drivers/of/address.c:__of_address_to_resource()
>     memset(r, 0, sizeof(struct resource));
>     ...
>     r->flags = ...
>     r->name = ...
>     r->start = ...
>     r->end = ...
> 
> This permanently corrupts the platform device's "ipa-shared" resource entry.
> While ipa->mem_addr and ipa->mem_size were saved before the corruption, the
> platform device's resource array is shared kernel infrastructure.
> 
> After this corruption:
> - /proc/iomem and sysfs will report incorrect resource information
> - If the driver is unbound and rebound, platform_get_resource_byname(pdev,
>   IORESOURCE_MEM, "ipa-shared") will fail because the resource's name field
>   was overwritten with the sram DT node's full_name, causing probe to fail
>   with -ENODEV
> 
> Would it be better to use a separate local variable for the
> of_address_to_resource() call?

Yes, the computer proved useful once again - I tunnel-visioned-out the
prior use of 'res'.

Konrad

      reply	other threads:[~2026-03-02 14:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-24 11:34 [net-next PATCH v5 0/3] Grab IPA IMEM slice through DT Konrad Dybcio
2026-02-24 11:34 ` [PATCH net-next v5 1/3] dt-bindings: sram: qcom,imem: Allow modem-tables subnode Konrad Dybcio
2026-02-24 11:34 ` [PATCH net-next v5 2/3] dt-bindings: net: qcom,ipa: Add sram property for describing IMEM slice Konrad Dybcio
2026-02-24 11:34 ` [PATCH net-next v5 3/3] net: ipa: Grab IMEM slice base/size from DTS Konrad Dybcio
2026-02-27  1:54   ` [net-next,v5,3/3] " Jakub Kicinski
2026-03-02 14:03     ` Konrad Dybcio [this message]

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=35b72adc-8f67-4cd1-a210-8bc88af39a5a@oss.qualcomm.com \
    --to=konrad.dybcio@oss.qualcomm.com \
    --cc=andersson@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=conor+dt@kernel.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=edumazet@google.com \
    --cc=elder@kernel.org \
    --cc=elder@riscstar.com \
    --cc=horms@kernel.org \
    --cc=konradybcio@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=krzk@kernel.org \
    --cc=krzysztof.kozlowski@oss.qualcomm.com \
    --cc=kuba@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marijn.suijten@somainline.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=robh@kernel.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

all inboxes | Powered by JetHome®