}
 }
 
-static void dpaa_fq_setup(struct dpaa_priv *priv,
-                         const struct dpaa_fq_cbs *fq_cbs,
-                         struct fman_port *tx_port)
+static int dpaa_fq_setup(struct dpaa_priv *priv,
+                        const struct dpaa_fq_cbs *fq_cbs,
+                        struct fman_port *tx_port)
 {
        int egress_cnt = 0, conf_cnt = 0, num_portals = 0, portal_cnt = 0, cpu;
        const cpumask_t *affine_cpus = qman_affine_cpus();
-       u16 channels[NR_CPUS];
        struct dpaa_fq *fq;
+       u16 *channels;
+
+       channels = kcalloc(num_possible_cpus(), sizeof(u16), GFP_KERNEL);
+       if (!channels)
+               return -ENOMEM;
 
        for_each_cpu_and(cpu, affine_cpus, cpu_online_mask)
                channels[num_portals++] = qman_affine_channel(cpu);
                                break;
                }
        }
+
+       kfree(channels);
+
+       return 0;
 }
 
 static inline int dpaa_tx_fq_to_id(const struct dpaa_priv *priv,
         */
        dpaa_eth_add_channel(priv->channel, &pdev->dev);
 
-       dpaa_fq_setup(priv, &dpaa_fq_cbs, priv->mac_dev->port[TX]);
+       err = dpaa_fq_setup(priv, &dpaa_fq_cbs, priv->mac_dev->port[TX]);
+       if (err)
+               goto free_dpaa_bps;
 
        /* Create a congestion group for this netdev, with
         * dynamically-allocated CGR ID.
 
                             struct netlink_ext_ack *extack)
 {
        const cpumask_t *cpus = qman_affine_cpus();
-       bool needs_revert[NR_CPUS] = {false};
        struct qman_portal *portal;
        u32 period, prev_period;
        u8 thresh, prev_thresh;
+       bool *needs_revert;
        int cpu, res;
 
+       needs_revert = kcalloc(num_possible_cpus(), sizeof(bool), GFP_KERNEL);
+       if (!needs_revert)
+               return -ENOMEM;
+
        period = c->rx_coalesce_usecs;
        thresh = c->rx_max_coalesced_frames;
 
                needs_revert[cpu] = true;
        }
 
+       kfree(needs_revert);
+
        return 0;
 
 revert_values:
                qman_dqrr_set_ithresh(portal, prev_thresh);
        }
 
+       kfree(needs_revert);
+
        return res;
 }