Skip to contentSkip to conversation

platform/x86: pmt: Fix a potential Oops on error in probe

PATCH In review Dan Carpenter 3 participants 3 messages Nov 17, 2020 – Nov 24, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86: pmt: Fix a potential Oops on error in probe

The "ns->attr_grp" pointer can be NULL so this error handling code needs to check for that to avoid an Oops.

Fixes e2729113ce66 ("platform/x86: Intel PMT class driver")
---
 drivers/platform/x86/intel_pmt_class.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/platform/x86/intel_pmt_class.c +2 -1
index aa88dc23bbde..c8939fba4509 100644
@@ -225,7 +225,8 @@ static int intel_pmt_dev_register(struct intel_pmt_entry *entry,
 		return 0;
 
 fail_ioremap:
-	sysfs_remove_group(entry->kobj, ns->attr_grp);
+	if (ns->attr_grp)
+		sysfs_remove_group(entry->kobj, ns->attr_grp);
 fail_sysfs:
 	device_unregister(dev);
 fail_dev_create:
Signature · 1 line
2.28.0
Reviewed-by on v1 1/1
#1 lore raw

Thanks Dan.

Quoted 26 lines · Dan Carpenter

The "ns->attr_grp" pointer can be NULL so this error handling code needs
to check for that to avoid an Oops.

Fixes e2729113ce66 ("platform/x86: Intel PMT class driver")
---
 drivers/platform/x86/intel_pmt_class.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/platform/x86/intel_pmt_class.c +2 -1
index aa88dc23bbde..c8939fba4509 100644
@@ -225,7 +225,8 @@ static int intel_pmt_dev_register(struct
 intel_pmt_entry *entry,
 		return 0;
 
 fail_ioremap:
-	sysfs_remove_group(entry->kobj, ns->attr_grp);
+	if (ns->attr_grp)
+		sysfs_remove_group(entry->kobj, ns->attr_grp);
 fail_sysfs:
 	device_unregister(dev);

fail_dev_create:

#2 lore raw
In reply to Dan Carpenter

Hi,

Quoted 5 lines · Dan Carpenter

The "ns->attr_grp" pointer can be NULL so this error handling code needs to check for that to avoid an Oops.

Fixes e2729113ce66 ("platform/x86: Intel PMT class driver")

Thank you for your patch, I've applied this patch to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.

Regards,

Hans

Quoted 19 lines
---
 drivers/platform/x86/intel_pmt_class.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/platform/x86/intel_pmt_class.c +2 -1
index aa88dc23bbde..c8939fba4509 100644
@@ -225,7 +225,8 @@ static int intel_pmt_dev_register(struct intel_pmt_entry *entry,
 		return 0;
 
 fail_ioremap:
-	sysfs_remove_group(entry->kobj, ns->attr_grp);
+	if (ns->attr_grp)
+		sysfs_remove_group(entry->kobj, ns->attr_grp);
 fail_sysfs:
 	device_unregister(dev);
 fail_dev_create: