[PATCH] platform/x86: Fix NULL deref in amd_isp_probe

Xueqin Luo <[email protected]>
Newsgroups org.kernel.vger.platform-driver-x86,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
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 <[email protected]>
---
 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.