Message ID | 20210329133528.22884-1-claudiu.manoil@nxp.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net] enetc: Avoid implicit sign extension | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | fail | Series targets non-next tree, but doesn't contain any Fixes tags |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for net |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | success | CCed 4 of 4 maintainers |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 3 this patch: 3 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 10 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 3 this patch: 3 |
netdev/header_inline | success | Link |
>-----Original Message----- >From: Claudiu Manoil <claudiu.manoil@nxp.com> >Sent: Monday, March 29, 2021 4:35 PM >To: netdev@vger.kernel.org >Cc: Jakub Kicinski <kuba@kernel.org>; David S . Miller ><davem@davemloft.net>; Vladimir Oltean <vladimir.oltean@nxp.com> >Subject: [PATCH net] enetc: Avoid implicit sign extension > >Static analysis tool reports: >"Suspicious implicit sign extension - 'flags' with type u8 (8 bit, >unsigned) is promoted in 'flags' << 24 to type int (32 bits, signed), >then sign-extended to type unsigned long long (64 bits, unsigned). >If flags << 24 is greater than 0x7FFFFFFF, the upper bits of the result >will all be 1." > >Use lower_32_bits() to avoid this scenario. > Fixes: 82728b91f124 ("enetc: Remove Tx checksumming offload code")
diff --git a/drivers/net/ethernet/freescale/enetc/enetc_hw.h b/drivers/net/ethernet/freescale/enetc/enetc_hw.h index 00938f7960a4..07e03df8af94 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_hw.h +++ b/drivers/net/ethernet/freescale/enetc/enetc_hw.h @@ -535,8 +535,8 @@ static inline __le32 enetc_txbd_set_tx_start(u64 tx_start, u8 flags) { u32 temp; - temp = (tx_start >> 5 & ENETC_TXBD_TXSTART_MASK) | - (flags << ENETC_TXBD_FLAGS_OFFSET); + temp = lower_32_bits(tx_start >> 5 & ENETC_TXBD_TXSTART_MASK) | + (u32)(flags << ENETC_TXBD_FLAGS_OFFSET); return cpu_to_le32(temp); }
Static analysis tool reports: "Suspicious implicit sign extension - 'flags' with type u8 (8 bit, unsigned) is promoted in 'flags' << 24 to type int (32 bits, signed), then sign-extended to type unsigned long long (64 bits, unsigned). If flags << 24 is greater than 0x7FFFFFFF, the upper bits of the result will all be 1." Use lower_32_bits() to avoid this scenario. Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com> --- drivers/net/ethernet/freescale/enetc/enetc_hw.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)