public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* drivers/net/ethernet/meta/fbnic/fbnic_tlv.h:83:24: warning: conversion from 'long unsigned int' to 'u16' {aka 'short unsigned int'} changes value from '261632' to '65024'
@ 2025-10-19  0:17 kernel test robot
  2025-10-21  9:42 ` [PATCH] eth: fbnic: fix integer overflow warning in TLV_MAX_DATA definition Pei Xiao
  0 siblings, 1 reply; 3+ messages in thread
From: kernel test robot @ 2025-10-19  0:17 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: oe-kbuild-all, linux-kernel, Paolo Abeni, Lee Trager,
	Simon Horman

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   1c64efcb083c48c85227cb4d72ab137feef2cdac
commit: 005a54722e9d493be58405a77f2a444e06f03be0 eth: fbnic: add FW health reporter
date:   4 weeks ago
config: powerpc-randconfig-002-20251019 (https://download.01.org/0day-ci/archive/20251019/202510190832.3SQkTCHe-lkp@intel.com/config)
compiler: powerpc-linux-gcc (GCC) 10.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251019/202510190832.3SQkTCHe-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202510190832.3SQkTCHe-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from drivers/net/ethernet/meta/fbnic/fbnic_devlink.c:12:
   drivers/net/ethernet/meta/fbnic/fbnic_devlink.c: In function 'fbnic_fw_reporter_dump':
>> drivers/net/ethernet/meta/fbnic/fbnic_tlv.h:83:24: warning: conversion from 'long unsigned int' to 'u16' {aka 'short unsigned int'} changes value from '261632' to '65024' [-Woverflow]
      83 | #define TLV_MAX_DATA   (PAGE_SIZE - 512)
         |                        ^
   drivers/net/ethernet/meta/fbnic/fbnic_devlink.c:429:31: note: in expansion of macro 'TLV_MAX_DATA'
     429 |  fw_cmpl->u.coredump.stride = TLV_MAX_DATA;
         |                               ^~~~~~~~~~~~


vim +83 drivers/net/ethernet/meta/fbnic/fbnic_tlv.h

c6203e678cc9a5 Alexander Duyck 2024-07-12  82  
c6203e678cc9a5 Alexander Duyck 2024-07-12 @83  #define TLV_MAX_DATA			(PAGE_SIZE - 512)
c6203e678cc9a5 Alexander Duyck 2024-07-12  84  #define FBNIC_TLV_ATTR_ID_UNKNOWN	USHRT_MAX
c6203e678cc9a5 Alexander Duyck 2024-07-12  85  #define FBNIC_TLV_ATTR_STRING(id, len)	{ id, len, FBNIC_TLV_STRING }
c6203e678cc9a5 Alexander Duyck 2024-07-12  86  #define FBNIC_TLV_ATTR_FLAG(id)		{ id, 0, FBNIC_TLV_FLAG }
c6203e678cc9a5 Alexander Duyck 2024-07-12  87  #define FBNIC_TLV_ATTR_U32(id)		{ id, sizeof(u32), FBNIC_TLV_UNSIGNED }
c6203e678cc9a5 Alexander Duyck 2024-07-12  88  #define FBNIC_TLV_ATTR_U64(id)		{ id, sizeof(u64), FBNIC_TLV_UNSIGNED }
c6203e678cc9a5 Alexander Duyck 2024-07-12  89  #define FBNIC_TLV_ATTR_S32(id)		{ id, sizeof(s32), FBNIC_TLV_SIGNED }
c6203e678cc9a5 Alexander Duyck 2024-07-12  90  #define FBNIC_TLV_ATTR_S64(id)		{ id, sizeof(s64), FBNIC_TLV_SIGNED }
c6203e678cc9a5 Alexander Duyck 2024-07-12  91  #define FBNIC_TLV_ATTR_MAC_ADDR(id)	{ id, ETH_ALEN, FBNIC_TLV_BINARY }
c6203e678cc9a5 Alexander Duyck 2024-07-12  92  #define FBNIC_TLV_ATTR_NESTED(id)	{ id, 0, FBNIC_TLV_NESTED }
c6203e678cc9a5 Alexander Duyck 2024-07-12  93  #define FBNIC_TLV_ATTR_ARRAY(id)	{ id, 0, FBNIC_TLV_ARRAY }
c6203e678cc9a5 Alexander Duyck 2024-07-12  94  #define FBNIC_TLV_ATTR_RAW_DATA(id)	{ id, TLV_MAX_DATA, FBNIC_TLV_BINARY }
c6203e678cc9a5 Alexander Duyck 2024-07-12  95  #define FBNIC_TLV_ATTR_LAST		{ FBNIC_TLV_ATTR_ID_UNKNOWN, 0, 0 }
c6203e678cc9a5 Alexander Duyck 2024-07-12  96  

:::::: The code at line 83 was first introduced by commit
:::::: c6203e678cc9a5bf01ec7ae382851f504870777f eth: fbnic: Add message parsing for FW messages

:::::: TO: Alexander Duyck <alexanderduyck@fb.com>
:::::: CC: Jakub Kicinski <kuba@kernel.org>

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] eth: fbnic: fix integer overflow warning in TLV_MAX_DATA definition
  2025-10-19  0:17 drivers/net/ethernet/meta/fbnic/fbnic_tlv.h:83:24: warning: conversion from 'long unsigned int' to 'u16' {aka 'short unsigned int'} changes value from '261632' to '65024' kernel test robot
@ 2025-10-21  9:42 ` Pei Xiao
  2025-10-23  3:46   ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 3+ messages in thread
From: Pei Xiao @ 2025-10-21  9:42 UTC (permalink / raw)
  To: lkp, alexanderduyck, kernel-team, netdev
  Cc: horms, kuba, lee, linux-kernel, oe-kbuild-all, pabeni, Pei Xiao

The TLV_MAX_DATA macro calculates (PAGE_SIZE - 512) which can exceed
the maximum value of a 16-bit unsigned integer on architectures with
large page sizes, causing compiler warnings:

drivers/net/ethernet/meta/fbnic/fbnic_tlv.h:83:24: warning: conversion
from 'long unsigned int' to 'short unsigned int' changes value from
'261632' to '65024' [-Woverflow]

Fix this by explicitly masking the result to 16 bits using bitwise AND
with 0xFFFF, ensuring the value fits within the expected data type
while maintaining the intended behavior for normal page sizes.

This preserves the existing functionality while eliminating the
compiler warning and potential undefined behavior from integer
truncation.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202510190832.3SQkTCHe-lkp@intel.com/
Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
---
 drivers/net/ethernet/meta/fbnic/fbnic_tlv.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_tlv.h b/drivers/net/ethernet/meta/fbnic/fbnic_tlv.h
index c34bf87eeec9..3508b46ebdd0 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_tlv.h
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_tlv.h
@@ -80,7 +80,7 @@ struct fbnic_tlv_index {
 	enum fbnic_tlv_type	type;
 };
 
-#define TLV_MAX_DATA			(PAGE_SIZE - 512)
+#define TLV_MAX_DATA			((PAGE_SIZE - 512) & 0xFFFF)
 #define FBNIC_TLV_ATTR_ID_UNKNOWN	USHRT_MAX
 #define FBNIC_TLV_ATTR_STRING(id, len)	{ id, len, FBNIC_TLV_STRING }
 #define FBNIC_TLV_ATTR_FLAG(id)		{ id, 0, FBNIC_TLV_FLAG }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] eth: fbnic: fix integer overflow warning in TLV_MAX_DATA definition
  2025-10-21  9:42 ` [PATCH] eth: fbnic: fix integer overflow warning in TLV_MAX_DATA definition Pei Xiao
@ 2025-10-23  3:46   ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-10-23  3:46 UTC (permalink / raw)
  To: Pei Xiao
  Cc: lkp, alexanderduyck, kernel-team, netdev, horms, kuba, lee,
	linux-kernel, oe-kbuild-all, pabeni

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 21 Oct 2025 17:42:27 +0800 you wrote:
> The TLV_MAX_DATA macro calculates (PAGE_SIZE - 512) which can exceed
> the maximum value of a 16-bit unsigned integer on architectures with
> large page sizes, causing compiler warnings:
> 
> drivers/net/ethernet/meta/fbnic/fbnic_tlv.h:83:24: warning: conversion
> from 'long unsigned int' to 'short unsigned int' changes value from
> '261632' to '65024' [-Woverflow]
> 
> [...]

Here is the summary with links:
  - eth: fbnic: fix integer overflow warning in TLV_MAX_DATA definition
    https://git.kernel.org/netdev/net-next/c/d550d63d0082

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-10-23  3:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-19  0:17 drivers/net/ethernet/meta/fbnic/fbnic_tlv.h:83:24: warning: conversion from 'long unsigned int' to 'u16' {aka 'short unsigned int'} changes value from '261632' to '65024' kernel test robot
2025-10-21  9:42 ` [PATCH] eth: fbnic: fix integer overflow warning in TLV_MAX_DATA definition Pei Xiao
2025-10-23  3:46   ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox