In a configuration where the base cgroup support is enabled but
every single cgroup subsys is turned off, CGROUP_BUILTIN_SUBSYS_COUNT
is zero, which causes the sanity check code in cgroup_load_subsys
to trigger:
BUG_ON(ss->subsys_id >= CGROUP_BUILTIN_SUBSYS_COUNT);
BUG_ON(subsys[ss->subsys_id] != ss);
Gcc first confirms that subsys_id cannot be 0 or larger and consequently
warns in the second line.
kernel/cgroup.c: In function 'cgroup_load_subsys':
kernel/cgroup.c:4326:38: warning: array subscript is below array bounds [-Warray-bounds]
Since the subsys_id can never be less than zero, we can just change the
type to an unsigned int, which makes the warning go away.
Found by building ARM cns3420vb_defconfig.
Signed-off-by: Arnd Bergmann <[email protected]>
Cc: Tejun Heo <[email protected]>
Cc: Li Zefan <[email protected]>
Cc: Ben Blum <[email protected]>
---
include/linux/cgroup.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index c90eaa8..26b99df 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -475,7 +475,7 @@ struct cgroup_subsys {
void (*post_clone)(struct cgroup *cgrp);
void (*bind)(struct cgroup *root);
- int subsys_id;
+ unsigned int subsys_id;
int active;
int disabled;
int early_init;
--
1.7.10
On Fri, Oct 05, 2012 at 04:55:21PM +0200, Arnd Bergmann wrote:
> In a configuration where the base cgroup support is enabled but
> every single cgroup subsys is turned off, CGROUP_BUILTIN_SUBSYS_COUNT
> is zero, which causes the sanity check code in cgroup_load_subsys
> to trigger:
>
> BUG_ON(ss->subsys_id >= CGROUP_BUILTIN_SUBSYS_COUNT);
> BUG_ON(subsys[ss->subsys_id] != ss);
>
> Gcc first confirms that subsys_id cannot be 0 or larger and consequently
> warns in the second line.
>
> kernel/cgroup.c: In function 'cgroup_load_subsys':
> kernel/cgroup.c:4326:38: warning: array subscript is below array bounds [-Warray-bounds]
>
> Since the subsys_id can never be less than zero, we can just change the
> type to an unsigned int, which makes the warning go away.
>
> Found by building ARM cns3420vb_defconfig.
>
> Signed-off-by: Arnd Bergmann <[email protected]>
> Cc: Tejun Heo <[email protected]>
> Cc: Li Zefan <[email protected]>
> Cc: Ben Blum <[email protected]>
> ---
> include/linux/cgroup.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
> index c90eaa8..26b99df 100644
> --- a/include/linux/cgroup.h
> +++ b/include/linux/cgroup.h
> @@ -475,7 +475,7 @@ struct cgroup_subsys {
> void (*post_clone)(struct cgroup *cgrp);
> void (*bind)(struct cgroup *root);
>
> - int subsys_id;
> + unsigned int subsys_id;
> int active;
> int disabled;
> int early_init;
> --
> 1.7.10
>
>
Oops. Thank you!
Acked-by: Ben Blum <[email protected]>
On Fri, Oct 05, 2012 at 04:55:21PM +0200, Arnd Bergmann wrote:
> In a configuration where the base cgroup support is enabled but
> every single cgroup subsys is turned off, CGROUP_BUILTIN_SUBSYS_COUNT
> is zero, which causes the sanity check code in cgroup_load_subsys
> to trigger:
>
> BUG_ON(ss->subsys_id >= CGROUP_BUILTIN_SUBSYS_COUNT);
> BUG_ON(subsys[ss->subsys_id] != ss);
CGROUP_BUILTIN_SUBSYS_COUNT is already gone in mainline. I suppose
this is no longer necessary?
Thanks.
--
tejun
On Saturday 06 October 2012, Tejun Heo wrote:
> On Fri, Oct 05, 2012 at 04:55:21PM +0200, Arnd Bergmann wrote:
> > In a configuration where the base cgroup support is enabled but
> > every single cgroup subsys is turned off, CGROUP_BUILTIN_SUBSYS_COUNT
> > is zero, which causes the sanity check code in cgroup_load_subsys
> > to trigger:
> >
> > BUG_ON(ss->subsys_id >= CGROUP_BUILTIN_SUBSYS_COUNT);
> > BUG_ON(subsys[ss->subsys_id] != ss);
>
> CGROUP_BUILTIN_SUBSYS_COUNT is already gone in mainline. I suppose
> this is no longer necessary?
Ah, you are right. I can confirm the problem is gone, and I'll drop
the patch.
Arnd