Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1357688
| Path | csiph.com!aioe.org!gothmog.csi.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | Arnd Bergmann <arnd@arndb.de> |
| Newsgroups | linux.kernel |
| Subject | [PATCH v2] cgroup: avoid false positive gcc-6 warning |
| Date | Tue, 15 Mar 2016 00:30:01 +0100 |
| Message-ID | <rcK5X-28k-3@gated-at.bofh.it> (permalink) |
| X-Original-To | Tejun Heo <tj@kernel.org>, Li Zefan <lizefan@huawei.com>, Johannes Weiner <hannes@cmpxchg.org> |
| X-Mailer | git-send-email 2.7.0 |
| X-Provags-ID | V03:K0:xhljZROxHATIIn5Q8DWE4+dE0ZY9qjupnzrUKsQcjD2CYz2RDSq Lg89peDYKZl0dHDHSbo/IqwolDPCWNgKEG1B6RRjF6Tx8nURSd+glSiEbg0l25iSF9TfaUx HKEWZ3QOU/2w6ry4bFYs4El4lkjH0uE8ys7H4VHYeBZPn0xu1DTY/OxS20n5Mbwbnolx0/k 5ZrkoI8szcKJ81bYnCt+Q== |
| X-Ui-Out-Filterresults | notjunk:1;V01:K0:PiovSi+iJXo=:QSe+oUZe6SBoIE17pBx98P N0cfEuR82vhWXXhq+8xAyijdKzocXQxIbVB2DHkikvlHwYckqtP0GKUXZZJujLH4uHbgZDHSW gfMywmI771EgW3Nxj13BnNtmaB6Gop/Syd1ch+guBP8rkhYDSydZ/80LSdW2Ov8XLcMibZHr7 8O/RxhZ0HlyxgXf0Kqndju/DiVzQTzjhmbhg1lxs7ovjWtNq22Dqi9hyav9rvZn2yEsiUCKtw JSQ+eqZ8RLlwBan6+45cm8+hkENhnUwfN0ioynAzfxHY8CVatFZQ/NI4oMfKKtmZW99LVXisA mZc3P7P/5hVqQqdVX0J/adclRV/q4tmGvAgUUPMQ3/eHblqOAnmO6WK3ZX4USoHTQDmX599EX jWgDCtaLiduHoNbfRHDdyQptH9+adS14En/snQ/XBjmtIClNjZGKaX9d4lxzmVhl3MHFui4uy F6p1moqoirMyiEQxZpVvDA5pqgZZ/ZOCCNqN7s9xi3eMzVXOMrh+Gd8LtrLgEmcADnGlcPCma RywoPf5VGaK2JSUKycXg3msFcb8IJIwQAzRZJKoJryBKzhPycXCeBuGaGUNRxa36dWnJk4j0b +sEwUmLbDMDLjkuRYoQCpZU9A6nRQQ0KRPUfdFW8KofY3+nZ862SEb3SGaOAVNi33wzM32BlL ofsnafq1v3osHnk2QIRPC+BWL5fH7DyYU6hMSQ0+7gV0o3b7jmTmbN7GBy6xgh+lS68A= |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 41 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | Arnd Bergmann <arnd@arndb.de>, Aditya Kali <adityakali@google.com>, Aleksa Sarai <cyphar@cyphar.com>, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org |
| X-Original-Date | Tue, 15 Mar 2016 00:21:06 +0100 |
| X-Original-Message-ID | <1457997681-2011105-1-git-send-email-arnd@arndb.de> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1357688 |
Show key headers only | View raw
When all subsystems are disabled, gcc notices that cgroup_subsys_enabled_key
is a zero-length array and that any access to it must be out of bounds:
In file included from ../include/linux/cgroup.h:19:0,
from ../kernel/cgroup.c:31:
../kernel/cgroup.c: In function 'cgroup_add_cftypes':
../kernel/cgroup.c:261:53: error: array subscript is above array bounds [-Werror=array-bounds]
return static_key_enabled(cgroup_subsys_enabled_key[ssid]);
~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
../include/linux/jump_label.h:271:40: note: in definition of macro 'static_key_enabled'
static_key_count((struct static_key *)x) > 0; \
^
We should never call the function in this particular case, so this is
not a bug. In order to silence the warning, this adds an explicit check
for the CGROUP_SUBSYS_COUNT==0 case.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
v2: use 'false' as the return code instead of '0', as suggested by
the friendly kbuild test robot.
kernel/cgroup.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 155c88470543..5f65c1002b4b 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -258,6 +258,9 @@ static int cgroup_addrm_files(struct cgroup_subsys_state *css,
*/
static bool cgroup_ssid_enabled(int ssid)
{
+ if (CGROUP_SUBSYS_COUNT == 0)
+ return false;
+
return static_key_enabled(cgroup_subsys_enabled_key[ssid]);
}
--
2.7.0
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH v2] cgroup: avoid false positive gcc-6 warning Arnd Bergmann <arnd@arndb.de> - 2016-03-15 00:30 +0100 Re: [PATCH v2] cgroup: avoid false positive gcc-6 warning Tejun Heo <tj@kernel.org> - 2016-03-16 21:40 +0100
csiph-web