Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

eth: fbnic: fix integer overflow warning in TLV_MAX_DATA definition

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>
Link: https://patch.msgid.link/182b9d0235d044d69d7a57c1296cc6f46e395beb.1761039651.git.xiaopei01@kylinos.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Pei Xiao and committed by
Jakub Kicinski
d550d63d 11457396

+1 -1
+1 -1
drivers/net/ethernet/meta/fbnic/fbnic_tlv.h
··· 80 80 enum fbnic_tlv_type type; 81 81 }; 82 82 83 - #define TLV_MAX_DATA (PAGE_SIZE - 512) 83 + #define TLV_MAX_DATA ((PAGE_SIZE - 512) & 0xFFFF) 84 84 #define FBNIC_TLV_ATTR_ID_UNKNOWN USHRT_MAX 85 85 #define FBNIC_TLV_ATTR_STRING(id, len) { id, len, FBNIC_TLV_STRING } 86 86 #define FBNIC_TLV_ATTR_FLAG(id) { id, 0, FBNIC_TLV_FLAG }