{
        void *hdr;
        int i, pages = 0;
-       uint32_t *buf = kcalloc(32, sizeof(uint32_t), GFP_KERNEL);
+       u32 *buf = kcalloc(IEEE802154_MAX_PAGE + 1, sizeof(u32), GFP_KERNEL);
 
        pr_debug("%s\n", __func__);
 
            nla_put_u8(msg, IEEE802154_ATTR_PAGE, phy->current_page) ||
            nla_put_u8(msg, IEEE802154_ATTR_CHANNEL, phy->current_channel))
                goto nla_put_failure;
-       for (i = 0; i < 32; i++) {
+       for (i = 0; i <= IEEE802154_MAX_PAGE; i++) {
                if (phy->supported.channels[i])
                        buf[pages++] = phy->supported.channels[i] | (i << 27);
        }