On Sun, Mar 01, 2026 at 04:09:25PM +0000, Simon Horman wrote:
> On Wed, Feb 25, 2026 at 05:06:45PM +0200, Ioana Ciornei wrote:
> 
> ...
> 
> > diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c 
> > b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
> 
> ...
> 
> > +static void dpaa2_mac_setup_stats(struct dpaa2_mac *mac, struct 
> > dpaa2_mac_stats *stats,
> > +                             size_t num_stats, const struct dpmac_counter 
> > *counters)
> > +{
> > +   struct device *dev = mac->net_dev->dev.parent;
> > +   u32 *cnt_idx;
> 
> Hi Ioana,
> 
> The type of cnt_idx is u32.
> 
> > +
> > +   stats->idx_dma_mem = kcalloc(num_stats, sizeof(u32), GFP_KERNEL);
> > +   if (!stats->idx_dma_mem)
> > +           goto out;
> > +
> > +   stats->values_dma_mem = kcalloc(num_stats, sizeof(u64), GFP_KERNEL);
> > +   if (!stats->values_dma_mem)
> > +           goto err_alloc_values;
> > +
> > +   cnt_idx = stats->idx_dma_mem;
> 
> As is that of idx_dma_mem. So the types match here.
> 
> > +   for (size_t i = 0; i < num_stats; i++)
> > +           *cnt_idx++ = cpu_to_le32((u32)(counters[i].id));
> 
> But here __le32 values are assigned to elements of cnt_idx.
> 
> I think that the type of both cnt_idx and stats->idx_dma_mem
> should probably be __le32 * rather than u32 *.
> 
> Flagged by Sparse v0.6.5-rc1.

Yes, I missed this. Thanks for catching it!
> 
> 
> ...
> 
> >  void dpaa2_mac_get_ethtool_stats(struct dpaa2_mac *mac, u64 *data)
> >  {
> > +   struct device *dev = mac->net_dev->dev.parent;
> >     struct fsl_mc_device *dpmac_dev = mac->mc_dev;
> > +   u64 *cnt_values;
> >     int i, err;
> >     u64 value;
> 
> ...
> 
> > +   cnt_values = mac->ethtool_stats.values_dma_mem;
> > +   for (i = 0; i < DPAA2_MAC_NUM_ETHTOOL_STATS; i++)
> > +           *(data + i) = le64_to_cpu(*cnt_values++);
> 
> Likewise, I think the type of both cnt_values and
> mac->ethtool_stats.values_dma_mem should be __le64 8 rather than u64 *.
> 
> And there is a similar problem in patch 3/5 centering on the use of
> le64_to_cpu() in dpaa2_mac_transfer_stats().
> 
> Also flagged by Sparse.
> 

Yes, this is valid too. Will fix.

Ioana

Reply via email to