kernel_samsung_a53x/drivers/net/ethernet/marvell
Kees Cook 034697940b sky2: Make sure there is at least one frag_addr available
[ Upstream commit 6a70e5cbedaf8ad10528ac9ac114f3ec20f422df ]

In the pathological case of building sky2 with 16k PAGE_SIZE, the
frag_addr[] array would never be used, so the original code was correct
that size should be 0. But the compiler now gets upset with 0 size arrays
in places where it hasn't eliminated the code that might access such an
array (it can't figure out that in this case an rx skb with fragments
would never be created). To keep the compiler happy, make sure there is
at least 1 frag_addr in struct rx_ring_info:

   In file included from include/linux/skbuff.h:28,
                    from include/net/net_namespace.h:43,
                    from include/linux/netdevice.h:38,
                    from drivers/net/ethernet/marvell/sky2.c:18:
   drivers/net/ethernet/marvell/sky2.c: In function 'sky2_rx_unmap_skb':
   include/linux/dma-mapping.h:416:36: warning: array subscript i is outside array bounds of 'dma_addr_t[0]' {aka 'long long unsigned int[]'} [-Warray-bounds=]
     416 | #define dma_unmap_page(d, a, s, r) dma_unmap_page_attrs(d, a, s, r, 0)
         |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/marvell/sky2.c:1257:17: note: in expansion of macro 'dma_unmap_page'
    1257 |                 dma_unmap_page(&pdev->dev, re->frag_addr[i],
         |                 ^~~~~~~~~~~~~~
   In file included from drivers/net/ethernet/marvell/sky2.c:41:
   drivers/net/ethernet/marvell/sky2.h:2198:25: note: while referencing 'frag_addr'
    2198 |         dma_addr_t      frag_addr[ETH_JUMBO_MTU >> PAGE_SHIFT];
         |                         ^~~~~~~~~

With CONFIG_PAGE_SIZE_16KB=y, PAGE_SHIFT == 14, so:

  #define ETH_JUMBO_MTU   9000

causes "ETH_JUMBO_MTU >> PAGE_SHIFT" to be 0. Use "?: 1" to solve this build warning.

Cc: Mirko Lindner <mlindner@marvell.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202309191958.UBw1cjXk-lkp@intel.com/
Reviewed-by: Alexander Lobakin <aleksander.lobakin@intel.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-08 11:26:17 +01:00
..
mvpp2 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
octeontx2 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
prestera Backport mac80211 patches from linux-6.1.y 2024-06-15 16:29:20 -03:00
Kconfig Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Makefile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mv643xx_eth.c Backport mac80211 patches from linux-6.1.y 2024-06-15 16:29:20 -03:00
mvmdio.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mvneta.c Backport mac80211 patches from linux-6.1.y 2024-06-15 16:29:20 -03:00
mvneta_bm.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mvneta_bm.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pxa168_eth.c Backport mac80211 patches from linux-6.1.y 2024-06-15 16:29:20 -03:00
skge.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
skge.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sky2.c Backport mac80211 patches from linux-6.1.y 2024-06-15 16:29:20 -03:00
sky2.h sky2: Make sure there is at least one frag_addr available 2024-11-08 11:26:17 +01:00