drm/amdgpu: Fix ISP segfault in kernel v7.0
Subsystems (2)
PATCH 1/1 drm/amdgpu: Fix ISP segfault in kernel v7.0
Add NULL pointer checks for dev->type before accessing dev->type->name in ISP genpd add/remove functions to prevent kernel crashes.
This regression was introduced in v7.0 as the wakeup sources are registered using physical device instead of ACPI device. This led to adding wakeup source device as the first child of AMDGPU device without initializing dev-type variable, and resulted in segfault when accessed it in the amdgpu isp driver.
--- drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c +2 -2
@@ -129,7 +129,7 @@ static int isp_genpd_add_device(struct device *dev, void *data)if (!pdev)return -EINVAL ; -if (!dev->type->name) { +if (!dev->type || !dev->type->name) {drm_dbg (&adev->ddev,"Invalid device type to add\n" ); goto exit; }
@@ -165,7 +165,7 @@ static int isp_genpd_remove_device(struct device *dev, void *data)if (!pdev)return -EINVAL ; -if (!dev->type->name) { +if (!dev->type || !dev->type->name) {drm_dbg (&adev->ddev,"Invalid device type to remove\n" ); goto exit; }
Signature · 1 line
2.43.0
Quoted 4 lines · Pratap Nirujogi
Add NULL pointer checks for
dev->typebefore accessingdev->type->namein ISP genpd add/remove functions to prevent kernel crashes.
Quoted 8 lines
This regression was introduced in v7.0 as the wakeup sources are registered using physical device instead of ACPI device. This led to adding wakeup source device as the first child of AMDGPU device without initializing dev-type variable, and resulted in segfault when accessed it in the amdgpu isp driver.
Fixes 057edc58aa59 ("ACPI: PM: Register wakeup sources under physical devices")Co-developed-by Bin Du <[email protected]>
Did this pass checkpatch? In order to use C-d-b this should have Bin's S-o-b I would expect too. If it was just his original idea for the issue and you implemented it a better tag would be Suggested-by.
Quoted 27 lines
Signed-off-by Pratap Nirujogi <[email protected]>--- drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c +2
-2@@ -129,7 +129,7 @@ static int isp_genpd_add_device(struct device *dev, void *data)if (!pdev)return -EINVAL ; -if (!dev->type->name) { +if (!dev->type || !dev->type->name) {drm_dbg (&adev->ddev,"Invalid device type to add\n" ); goto exit; }@@ -165,7 +165,7 @@ static int isp_genpd_remove_device(struct device *dev, void *data)if (!pdev)return -EINVAL ; -if (!dev->type->name) { +if (!dev->type || !dev->type->name) {drm_dbg (&adev->ddev,"Invalid device type to remove\n" ); goto exit; }
Quoted 13 lines · Mario Limonciello
Quoted 10 lines · Pratap Nirujogi
Add NULL pointer checks for
dev->typebefore accessingdev->type->namein ISP genpd add/remove functions to prevent kernel crashes.This regression was introduced in v7.0 as the wakeup sources are registered using physical device instead of ACPI device. This led to adding wakeup source device as the first child of AMDGPU device without initializing dev-type variable, and resulted in segfault when accessed it in the amdgpu isp driver.
Quoted 5 lines
Quoted 2 lines
Fixes 057edc58aa59 ("ACPI: PM: Register wakeup sources under physical devices")Co-developed-by Bin Du <[email protected]>Did this pass checkpatch? In order to use C-d-b this should have Bin's S-o-b I would expect too. If it was just his original idea for the issue and you implemented it a better tag would be Suggested-by.
I missed the warning checkpatch reported, will fix it in v2. Sure, will use Suggested-by tag as well.
Thanks,
Pratap
Quoted 28 lines
Quoted 27 lines
Signed-off-by Pratap Nirujogi <[email protected]>---
drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c +2
-2@@ -129,7 +129,7 @@ static int isp_genpd_add_device(struct device *dev, void *data) if (!pdev) return -EINVAL; - if (!dev->type->name) { + if (!dev->type || !dev->type->name) { drm_dbg(&adev->ddev, "Invalid device type to add\n"); goto exit; }@@ -165,7 +165,7 @@ static int isp_genpd_remove_device(struct device *dev, void *data) if (!pdev) return -EINVAL; - if (!dev->type->name) { + if (!dev->type || !dev->type->name) { drm_dbg(&adev->ddev, "Invalid device type to remove\n"); goto exit; }