mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] platform/x86: Fix NULL deref in amd_isp_probe
@ 2026-08-10  3:24 Xueqin Luo
  2026-08-10 21:52 ` Nirujogi, Pratap
  0 siblings, 1 reply; 4+ messages in thread
From: Xueqin Luo @ 2026-08-10  3:24 UTC (permalink / raw)
  To: hansg, ilpo.jarvinen
  Cc: pratap.nirujogi, mario.limonciello, platform-driver-x86,
	linux-kernel, Xueqin Luo

amd_isp_probe() uses ACPI_COMPANION() without NULL check. Add it to
prevent crash when driver_override matches a device without ACPI
companion.

Fixes: e1af6f0146d6 ("platform/x86: Update swnode graph for amd isp4")
Signed-off-by: Xueqin Luo <luoxueqin@kylinos.cn>
---
 drivers/platform/x86/amd/amd_isp4.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/platform/x86/amd/amd_isp4.c b/drivers/platform/x86/amd/amd_isp4.c
index 0d494899502c..0026d6663c5c 100644
--- a/drivers/platform/x86/amd/amd_isp4.c
+++ b/drivers/platform/x86/amd/amd_isp4.c
@@ -379,6 +379,11 @@ static int amd_isp_probe(struct platform_device *pdev)
 		goto error_unregister_sw_node;
 
 	adev = ACPI_COMPANION(&pdev->dev);
+	if (!adev) {
+		ret = -ENODEV;
+		goto error_unregister_notifier;
+	}
+
 	/* initialize root amd_camera_node */
 	adev->driver_data = (void *)pinfo->swnodes[0];
 
@@ -388,6 +393,8 @@ static int amd_isp_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, isp4_platform);
 	return 0;
 
+error_unregister_notifier:
+	bus_unregister_notifier(&i2c_bus_type, &isp4_platform->i2c_nb);
 error_unregister_sw_node:
 	software_node_unregister_node_group(isp4_platform->pinfo->swnodes);
 	return ret;
-- 
2.43.0


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

* Re: [PATCH] platform/x86: Fix NULL deref in amd_isp_probe
  2026-08-10  3:24 [PATCH] platform/x86: Fix NULL deref in amd_isp_probe Xueqin Luo
@ 2026-08-10 21:52 ` Nirujogi, Pratap
  2026-08-11 15:37   ` Mario Limonciello
  0 siblings, 1 reply; 4+ messages in thread
From: Nirujogi, Pratap @ 2026-08-10 21:52 UTC (permalink / raw)
  To: Xueqin Luo, hansg, ilpo.jarvinen
  Cc: pratap.nirujogi, mario.limonciello, platform-driver-x86, linux-kernel



On 8/9/2026 11:24 PM, Xueqin Luo wrote:
> [You don't often get email from luoxueqin@kylinos.cn. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
> 
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
> 
> 
> amd_isp_probe() uses ACPI_COMPANION() without NULL check. Add it to
> prevent crash when driver_override matches a device without ACPI
> companion.
> 
> Fixes: e1af6f0146d6 ("platform/x86: Update swnode graph for amd isp4")
> Signed-off-by: Xueqin Luo <luoxueqin@kylinos.cn>
> ---
>   drivers/platform/x86/amd/amd_isp4.c | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/platform/x86/amd/amd_isp4.c b/drivers/platform/x86/amd/amd_isp4.c
> index 0d494899502c..0026d6663c5c 100644
> --- a/drivers/platform/x86/amd/amd_isp4.c
> +++ b/drivers/platform/x86/amd/amd_isp4.c
> @@ -379,6 +379,11 @@ static int amd_isp_probe(struct platform_device *pdev)
>                  goto error_unregister_sw_node;
> 
>          adev = ACPI_COMPANION(&pdev->dev);
> +       if (!adev) {
> +               ret = -ENODEV;
> +               goto error_unregister_notifier;
> +       }
> +
>          /* initialize root amd_camera_node */
>          adev->driver_data = (void *)pinfo->swnodes[0];
> 
> @@ -388,6 +393,8 @@ static int amd_isp_probe(struct platform_device *pdev)
>          platform_set_drvdata(pdev, isp4_platform);
>          return 0;
> 
> +error_unregister_notifier:
> +       bus_unregister_notifier(&i2c_bus_type, &isp4_platform->i2c_nb);
>   error_unregister_sw_node:
>          software_node_unregister_node_group(isp4_platform->pinfo->swnodes);
>          return ret;
LGTM. I agree that adding the NULL check is good practice. That said, I 
believe it's not strictly needed as the device_get_match_data() in 
line#366 is expected to fail if there is no ACPI companion.

https://github.com/torvalds/linux/blob/master/drivers/platform/x86/amd/amd_isp4.c#L366

Reviewed-by: Pratap Nirujogi <pratap.nirujogi@amd.com>

> --
> 2.43.0
> 


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

* Re: [PATCH] platform/x86: Fix NULL deref in amd_isp_probe
  2026-08-10 21:52 ` Nirujogi, Pratap
@ 2026-08-11 15:37   ` Mario Limonciello
  2026-09-15 20:24     ` Ilpo Järvinen
  0 siblings, 1 reply; 4+ messages in thread
From: Mario Limonciello @ 2026-08-11 15:37 UTC (permalink / raw)
  To: Nirujogi, Pratap, Xueqin Luo, hansg, ilpo.jarvinen
  Cc: pratap.nirujogi, platform-driver-x86, linux-kernel



On 8/10/26 16:52, Nirujogi, Pratap wrote:
> 
> 
> On 8/9/2026 11:24 PM, Xueqin Luo wrote:
>> [You don't often get email from luoxueqin@kylinos.cn. Learn why this 
>> is important at https://aka.ms/LearnAboutSenderIdentification ]
>>
>> Caution: This message originated from an External Source. Use proper 
>> caution when opening attachments, clicking links, or responding.
>>
>>
>> amd_isp_probe() uses ACPI_COMPANION() without NULL check. Add it to
>> prevent crash when driver_override matches a device without ACPI
>> companion.
>>
>> Fixes: e1af6f0146d6 ("platform/x86: Update swnode graph for amd isp4")
>> Signed-off-by: Xueqin Luo <luoxueqin@kylinos.cn>
>> ---
>>   drivers/platform/x86/amd/amd_isp4.c | 7 +++++++
>>   1 file changed, 7 insertions(+)
>>
>> diff --git a/drivers/platform/x86/amd/amd_isp4.c b/drivers/platform/ 
>> x86/amd/amd_isp4.c
>> index 0d494899502c..0026d6663c5c 100644
>> --- a/drivers/platform/x86/amd/amd_isp4.c
>> +++ b/drivers/platform/x86/amd/amd_isp4.c
>> @@ -379,6 +379,11 @@ static int amd_isp_probe(struct platform_device 
>> *pdev)
>>                  goto error_unregister_sw_node;
>>
>>          adev = ACPI_COMPANION(&pdev->dev);
>> +       if (!adev) {
>> +               ret = -ENODEV;
>> +               goto error_unregister_notifier;
>> +       }
>> +
>>          /* initialize root amd_camera_node */
>>          adev->driver_data = (void *)pinfo->swnodes[0];
>>
>> @@ -388,6 +393,8 @@ static int amd_isp_probe(struct platform_device 
>> *pdev)
>>          platform_set_drvdata(pdev, isp4_platform);
>>          return 0;
>>
>> +error_unregister_notifier:
>> +       bus_unregister_notifier(&i2c_bus_type, &isp4_platform->i2c_nb);
>>   error_unregister_sw_node:
>>          software_node_unregister_node_group(isp4_platform->pinfo- 
>> >swnodes);
>>          return ret;
> LGTM. I agree that adding the NULL check is good practice. That said, I 
> believe it's not strictly needed as the device_get_match_data() in 
> line#366 is expected to fail if there is no ACPI companion.

It sounds like it's essentially dead code then.

> 
> https://github.com/torvalds/linux/blob/master/drivers/platform/x86/amd/ 
> amd_isp4.c#L366
> 
> Reviewed-by: Pratap Nirujogi <pratap.nirujogi@amd.com>
> 
>> -- 
>> 2.43.0
>>
> 


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

* Re: [PATCH] platform/x86: Fix NULL deref in amd_isp_probe
  2026-08-11 15:37   ` Mario Limonciello
@ 2026-09-15 20:24     ` Ilpo Järvinen
  0 siblings, 0 replies; 4+ messages in thread
From: Ilpo Järvinen @ 2026-09-15 20:24 UTC (permalink / raw)
  To: Mario Limonciello
  Cc: Nirujogi, Pratap, Xueqin Luo, Hans de Goede, pratap.nirujogi,
	platform-driver-x86, LKML

[-- Attachment #1: Type: text/plain, Size: 2731 bytes --]

On Tue, 11 Aug 2026, Mario Limonciello wrote:

> 
> 
> On 8/10/26 16:52, Nirujogi, Pratap wrote:
> > 
> > 
> > On 8/9/2026 11:24 PM, Xueqin Luo wrote:
> > > [You don't often get email from luoxueqin@kylinos.cn. Learn why this is
> > > important at https://aka.ms/LearnAboutSenderIdentification ]
> > > 
> > > Caution: This message originated from an External Source. Use proper
> > > caution when opening attachments, clicking links, or responding.
> > > 
> > > 
> > > amd_isp_probe() uses ACPI_COMPANION() without NULL check. Add it to
> > > prevent crash when driver_override matches a device without ACPI
> > > companion.
> > > 
> > > Fixes: e1af6f0146d6 ("platform/x86: Update swnode graph for amd isp4")
> > > Signed-off-by: Xueqin Luo <luoxueqin@kylinos.cn>
> > > ---
> > >   drivers/platform/x86/amd/amd_isp4.c | 7 +++++++
> > >   1 file changed, 7 insertions(+)
> > > 
> > > diff --git a/drivers/platform/x86/amd/amd_isp4.c b/drivers/platform/
> > > x86/amd/amd_isp4.c
> > > index 0d494899502c..0026d6663c5c 100644
> > > --- a/drivers/platform/x86/amd/amd_isp4.c
> > > +++ b/drivers/platform/x86/amd/amd_isp4.c
> > > @@ -379,6 +379,11 @@ static int amd_isp_probe(struct platform_device
> > > *pdev)
> > >                  goto error_unregister_sw_node;
> > > 
> > >          adev = ACPI_COMPANION(&pdev->dev);
> > > +       if (!adev) {
> > > +               ret = -ENODEV;
> > > +               goto error_unregister_notifier;
> > > +       }
> > > +
> > >          /* initialize root amd_camera_node */
> > >          adev->driver_data = (void *)pinfo->swnodes[0];
> > > 
> > > @@ -388,6 +393,8 @@ static int amd_isp_probe(struct platform_device *pdev)
> > >          platform_set_drvdata(pdev, isp4_platform);
> > >          return 0;
> > > 
> > > +error_unregister_notifier:
> > > +       bus_unregister_notifier(&i2c_bus_type, &isp4_platform->i2c_nb);
> > >   error_unregister_sw_node:
> > >          software_node_unregister_node_group(isp4_platform->pinfo-
> > > >swnodes);
> > >          return ret;
> > LGTM. I agree that adding the NULL check is good practice. That said, I
> > believe it's not strictly needed as the device_get_match_data() in line#366
> > is expected to fail if there is no ACPI companion.
> 
> It sounds like it's essentially dead code then.

Yeah, lets not add dead-code NULL checks.

> > https://github.com/torvalds/linux/blob/master/drivers/platform/x86/amd/
> > amd_isp4.c#L366
> > 
> > Reviewed-by: Pratap Nirujogi <pratap.nirujogi@amd.com>
> > 
> > > -- 
> > > 2.43.0
> > > 
> > 
> 

-- 
 i.

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

end of thread, other threads:[~2026-09-15 20:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-10  3:24 [PATCH] platform/x86: Fix NULL deref in amd_isp_probe Xueqin Luo
2026-08-10 21:52 ` Nirujogi, Pratap
2026-08-11 15:37   ` Mario Limonciello
2026-09-15 20:24     ` Ilpo Järvinen

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®