Re: [PATCH v8] platform: x86: Add ChromeOS ACPI device driver

From: Greg Kroah-Hartman
Date: Sun Apr 24 2022 - 04:43:35 EST


On Fri, Apr 15, 2022 at 10:08:15PM +0500, Muhammad Usama Anjum wrote:
> + i = 0;
> + list_for_each_entry(aag, &chromeos_acpi.groups, list) {
> + chromeos_acpi.dev_groups[i] = &aag->group;
> + i++;
> + }
> +
> + ret = sysfs_create_groups(&dev->kobj, chromeos_acpi.dev_groups);

You have raced with userspace and lost here :(

Use the default groups pointer in the platform driver for this, and use
the is_visible() callback to know to show, or not show, the attribute
instead of building up dynamic lists of attributes at runtime. That
will save you lots of crazy logic and housekeeping _AND_ userspace tools
will work properly as well.

thanks,

greg k-h