public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next] spmi: pmic-arb: Add check for return value of platform_get_resource_byname
@ 2024-08-03  6:56 Gaosheng Cui
  2024-08-05 21:55 ` Stephen Boyd
  0 siblings, 1 reply; 4+ messages in thread
From: Gaosheng Cui @ 2024-08-03  6:56 UTC (permalink / raw)
  To: sboyd, cuigaosheng1; +Cc: linux-kernel

Add check for the return value of platform_get_resource_byname() and
return the error if it fails to catch the error.

Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
---
 drivers/spmi/spmi-pmic-arb.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/spmi/spmi-pmic-arb.c b/drivers/spmi/spmi-pmic-arb.c
index 9ba9495fcc4b..5f5f2f0a10b9 100644
--- a/drivers/spmi/spmi-pmic-arb.c
+++ b/drivers/spmi/spmi-pmic-arb.c
@@ -1808,6 +1808,9 @@ static int spmi_pmic_arb_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "core");
+	if (!res)
+		return -EINVAL;
+
 	core = devm_ioremap(dev, res->start, resource_size(res));
 	if (!core)
 		return -ENOMEM;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH -next] spmi: pmic-arb: Add check for return value of platform_get_resource_byname
  2024-08-03  6:56 [PATCH -next] spmi: pmic-arb: Add check for return value of platform_get_resource_byname Gaosheng Cui
@ 2024-08-05 21:55 ` Stephen Boyd
  2024-08-06 12:06   ` cuigaosheng
  0 siblings, 1 reply; 4+ messages in thread
From: Stephen Boyd @ 2024-08-05 21:55 UTC (permalink / raw)
  To: cuigaosheng1; +Cc: linux-kernel

Quoting Gaosheng Cui (2024-08-02 23:56:25)
> Add check for the return value of platform_get_resource_byname() and
> return the error if it fails to catch the error.
> 
> Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>

Is this the right fixes tag?

Fixes: b319b5922db2 ("spmi: pmic-arb: remove the read/write access checks")

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -next] spmi: pmic-arb: Add check for return value of platform_get_resource_byname
  2024-08-05 21:55 ` Stephen Boyd
@ 2024-08-06 12:06   ` cuigaosheng
  2024-08-06 17:50     ` Stephen Boyd
  0 siblings, 1 reply; 4+ messages in thread
From: cuigaosheng @ 2024-08-06 12:06 UTC (permalink / raw)
  To: Stephen Boyd; +Cc: linux-kernel

Thanks for your time.

I've made and submitted a patch v2, and I think the right fixes tag is 
as follows:

Fixes: 39ae93e3a31d ("spmi: Add MSM PMIC Arbiter SPMI controller")


On 2024/8/6 5:55, Stephen Boyd wrote:
> Quoting Gaosheng Cui (2024-08-02 23:56:25)
>> Add check for the return value of platform_get_resource_byname() and
>> return the error if it fails to catch the error.
>>
>> Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
> Is this the right fixes tag?
>
> Fixes: b319b5922db2 ("spmi: pmic-arb: remove the read/write access checks")
> .

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -next] spmi: pmic-arb: Add check for return value of platform_get_resource_byname
  2024-08-06 12:06   ` cuigaosheng
@ 2024-08-06 17:50     ` Stephen Boyd
  0 siblings, 0 replies; 4+ messages in thread
From: Stephen Boyd @ 2024-08-06 17:50 UTC (permalink / raw)
  To: cuigaosheng; +Cc: linux-kernel

Quoting cuigaosheng (2024-08-06 05:06:40)
> Thanks for your time.

Please don't top post.

> 
> I've made and submitted a patch v2, and I think the right fixes tag is 
> as follows:
> 
> Fixes: 39ae93e3a31d ("spmi: Add MSM PMIC Arbiter SPMI controller")

Don't think so. If the resource isn't there, the pointer returned is
NULL, devm_ioremap_resource() would bail out early if the resource is
NULL and return an error. I suggested that fixes tag because it removed
the size check. But now I see that resource_size() on a NULL pointer
would blow up. So the real fixes tag is

Fixes: 987a9f128b8a ("spmi: pmic-arb: Support more than 128 peripherals")

because that introduced the call to resource_size() on a potentially
NULL pointer.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-08-06 17:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-03  6:56 [PATCH -next] spmi: pmic-arb: Add check for return value of platform_get_resource_byname Gaosheng Cui
2024-08-05 21:55 ` Stephen Boyd
2024-08-06 12:06   ` cuigaosheng
2024-08-06 17:50     ` Stephen Boyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox