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: a1944676767e ("misc: keba: Add basic KEBA CP500 system FPGA support")
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Gerhard Engleder <eg@keba.com>
Link: https://lore.kernel.org/r/20240819192645.50171-1-gerhard@engleder-embedded.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by Gerhard Engleder and committed by Greg Kroah-Hartman 7d32e779 a759d1f2

+4 -10
+4 -10
drivers/misc/keba/cp500.c
··· 212 212 } 213 213 static DEVICE_ATTR_RW(keep_cfg); 214 214 215 - static struct attribute *attrs[] = { 215 + static struct attribute *cp500_attrs[] = { 216 216 &dev_attr_version.attr, 217 217 &dev_attr_keep_cfg.attr, 218 218 NULL 219 219 }; 220 - static const struct attribute_group attrs_group = { .attrs = attrs }; 220 + ATTRIBUTE_GROUPS(cp500); 221 221 222 222 static void cp500_i2c_release(struct device *dev) 223 223 { ··· 396 396 397 397 pci_set_drvdata(pci_dev, cp500); 398 398 399 - ret = sysfs_create_group(&pci_dev->dev.kobj, &attrs_group); 400 - if (ret != 0) 401 - goto out_free_irq; 402 399 403 400 ret = cp500_enable(cp500); 404 401 if (ret != 0) 405 - goto out_remove_group; 402 + goto out_free_irq; 406 403 407 404 cp500_register_auxiliary_devs(cp500); 408 405 409 406 return 0; 410 407 411 - out_remove_group: 412 - sysfs_remove_group(&pci_dev->dev.kobj, &attrs_group); 413 408 out_free_irq: 414 409 pci_free_irq_vectors(pci_dev); 415 410 out_disable: ··· 421 426 cp500_unregister_auxiliary_devs(cp500); 422 427 423 428 cp500_disable(cp500); 424 - 425 - sysfs_remove_group(&pci_dev->dev.kobj, &attrs_group); 426 429 427 430 pci_set_drvdata(pci_dev, 0); 428 431 ··· 443 450 .id_table = cp500_ids, 444 451 .probe = cp500_probe, 445 452 .remove = cp500_remove, 453 + .dev_groups = cp500_groups, 446 454 }; 447 455 module_pci_driver(cp500_driver); 448 456