From patchwork Sun Nov 20 17:36:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 9438557 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D063960235 for ; Sun, 20 Nov 2016 17:36:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C50D228904 for ; Sun, 20 Nov 2016 17:36:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA0C2289B3; Sun, 20 Nov 2016 17:36:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 68E9328904 for ; Sun, 20 Nov 2016 17:36:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753000AbcKTRgi (ORCPT ); Sun, 20 Nov 2016 12:36:38 -0500 Received: from bh-25.webhostbox.net ([208.91.199.152]:59151 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752957AbcKTRgh (ORCPT ); Sun, 20 Nov 2016 12:36:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=roeck-us.net; s=default; h=References:In-Reply-To:Message-Id:Date:Subject: Cc:To:From; bh=6OXIMbV6UlLYf9431X5n811qhRID6NDME5yWAm1J3+s=; b=MfUZcnJbpYpO6H ZM6+mMrN4jMfuGJ5t1ZFt1Wzg9entAbGRn7q2mPpFkejitWFQOCWrwIsoy4M1GW8Sf07+vTGHAfXs 5KcoRx7fefc1p/cMF0ycpqBhpttCuP/HCYtl0BxR+pt+JMe089HtTQ7kooYgaRr5z4/fOF/ehzd/Z SKLmnS8NrVvI2jBAUpX2pqS18nJZouP4fLXWFxmqFOBSSbjK56KS9UKqjkoZTTFqOlao88Hq7q3S2 XeVF3bhOZOQ9kLlBzA0LWMtqX4LdoeM6aM5t0xQOA6/E29cdiZ1UpQwFrEXQDzeZhTLjH5mibsJZs 55ftKOWvseJOIzIqoQSQ==; Received: from 108-223-40-66.lightspeed.sntcca.sbcglobal.net ([108.223.40.66]:42458 helo=localhost) by bh-25.webhostbox.net with esmtpa (Exim 4.86_1) (envelope-from ) id 1c8W2c-0034NV-08; Sun, 20 Nov 2016 17:36:34 +0000 From: Guenter Roeck To: Hardware Monitoring Cc: Jean Delvare , Guenter Roeck Subject: [PATCH 6/7] hwmon: (core) Explain why at least two attribute groups are allocated Date: Sun, 20 Nov 2016 09:36:27 -0800 Message-Id: <1479663388-2000-6-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1479663388-2000-1-git-send-email-linux@roeck-us.net> References: <1479663388-2000-1-git-send-email-linux@roeck-us.net> X-Authenticated_sender: guenter@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: guenter@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: guenter@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/hwmon/hwmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c index a0b5becf91fa..8dc0466a9307 100644 --- a/drivers/hwmon/hwmon.c +++ b/drivers/hwmon/hwmon.c @@ -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++)