]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
hwmon: (core) Explain why at least two attribute groups are allocated
authorGuenter Roeck <linux@roeck-us.net>
Mon, 17 Oct 2016 00:11:52 +0000 (17:11 -0700)
committerGuenter Roeck <linux@roeck-us.net>
Sat, 10 Dec 2016 05:54:21 +0000 (21:54 -0800)
A list of sysfs attribute groups is NULL-terminated, so we always need
to allocate data for at least two groups (the dynamically generated group
plus the NULL pointer). Add a comment to explain the situation.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/hwmon.c

index a0b5becf91fa5a77c38860983f2eaea07023fb6f..8dc0466a93072dbb2c581753bd588ee414671bce 100644 (file)
@@ -561,7 +561,7 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata,
 
        if (chip) {
                struct attribute **attrs;
-               int ngroups = 2;
+               int ngroups = 2; /* terminating NULL plus &hwdev->groups */
 
                if (groups)
                        for (i = 0; groups[i]; i++)