Skip to content

Commit 7d32e77

Browse files
Gerhard Engledergregkh
authored andcommitted
misc: keba: Fix sysfs group creation
sysfs_create_group() races with userspace. Use dev_groups instead which prevents all the problems of sysfs_create_group(). Fixes: a194467 ("misc: keba: Add basic KEBA CP500 system FPGA support") Suggested-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Gerhard Engleder <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent a759d1f commit 7d32e77

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

drivers/misc/keba/cp500.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,12 @@ static ssize_t keep_cfg_store(struct device *dev, struct device_attribute *attr,
212212
}
213213
static DEVICE_ATTR_RW(keep_cfg);
214214

215-
static struct attribute *attrs[] = {
215+
static struct attribute *cp500_attrs[] = {
216216
&dev_attr_version.attr,
217217
&dev_attr_keep_cfg.attr,
218218
NULL
219219
};
220-
static const struct attribute_group attrs_group = { .attrs = attrs };
220+
ATTRIBUTE_GROUPS(cp500);
221221

222222
static void cp500_i2c_release(struct device *dev)
223223
{
@@ -396,20 +396,15 @@ static int cp500_probe(struct pci_dev *pci_dev, const struct pci_device_id *id)
396396

397397
pci_set_drvdata(pci_dev, cp500);
398398

399-
ret = sysfs_create_group(&pci_dev->dev.kobj, &attrs_group);
400-
if (ret != 0)
401-
goto out_free_irq;
402399

403400
ret = cp500_enable(cp500);
404401
if (ret != 0)
405-
goto out_remove_group;
402+
goto out_free_irq;
406403

407404
cp500_register_auxiliary_devs(cp500);
408405

409406
return 0;
410407

411-
out_remove_group:
412-
sysfs_remove_group(&pci_dev->dev.kobj, &attrs_group);
413408
out_free_irq:
414409
pci_free_irq_vectors(pci_dev);
415410
out_disable:
@@ -427,8 +422,6 @@ static void cp500_remove(struct pci_dev *pci_dev)
427422

428423
cp500_disable(cp500);
429424

430-
sysfs_remove_group(&pci_dev->dev.kobj, &attrs_group);
431-
432425
pci_set_drvdata(pci_dev, 0);
433426

434427
pci_free_irq_vectors(pci_dev);
@@ -450,6 +443,7 @@ static struct pci_driver cp500_driver = {
450443
.id_table = cp500_ids,
451444
.probe = cp500_probe,
452445
.remove = cp500_remove,
446+
.dev_groups = cp500_groups,
453447
};
454448
module_pci_driver(cp500_driver);
455449

0 commit comments

Comments
 (0)