Manually rebased: backport-5.10/811-v6.1-0001-nvmem-core-Fix-memleak-in-nvmem_register.patch Removed upstreamed: backport-5.10/811-v6.1-0003-nvmem-core-add-error-handling-for-dev_set_name.patch[1] patches-5.10/070-net-bgmac-fix-BCM5358-support-by-setting-correct-fla.patch[2] Add fix: target/linux/generic/backport-5.10/804-0001-net-Remove-WARN_ON_ONCE-sk-sk_forward_alloc-from-sk_.patch[3] All other patches automatically rebased. 1. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.10.169&id=a19a0f67dbb89ad2bfc466f2003841acba645884 2. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.10.169&id=a5c51e0c3202820192db3f3809e072f3ca2b1177 3. https://lore.kernel.org/stable/20230227211548.13923-1-kuniyu@amazon.com Signed-off-by: John Audia <therealgraysky@proton.me>
35 lines
1.4 KiB
Diff
35 lines
1.4 KiB
Diff
From 55022fdeace8e432f008787ce03703bdcc9c3ca9 Mon Sep 17 00:00:00 2001
|
|
From: Colin Ian King <colin.king@canonical.com>
|
|
Date: Tue, 30 Mar 2021 12:12:38 +0100
|
|
Subject: [PATCH] nvmem: core: Fix unintentional sign extension issue
|
|
|
|
The shifting of the u8 integer buf[3] by 24 bits to the left will
|
|
be promoted to a 32 bit signed int and then sign-extended to a
|
|
u64. In the event that the top bit of buf[3] is set then all
|
|
then all the upper 32 bits of the u64 end up as also being set
|
|
because of the sign-extension. Fix this by casting buf[i] to
|
|
a u64 before the shift.
|
|
|
|
Fixes: a28e824fb827 ("nvmem: core: Add functions to make number reading easy")
|
|
Reviewed-by: Douglas Anderson <dianders@chromium.org>
|
|
Signed-off-by: Colin Ian King <colin.king@canonical.com>
|
|
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
|
Addresses-Coverity: ("Unintended sign extension")
|
|
Link: https://lore.kernel.org/r/20210330111241.19401-8-srinivas.kandagatla@linaro.org
|
|
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
|
---
|
|
drivers/nvmem/core.c | 2 +-
|
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
|
--- a/drivers/nvmem/core.c
|
|
+++ b/drivers/nvmem/core.c
|
|
@@ -1700,7 +1700,7 @@ int nvmem_cell_read_variable_le_u64(stru
|
|
/* Copy w/ implicit endian conversion */
|
|
*val = 0;
|
|
for (i = 0; i < len; i++)
|
|
- *val |= buf[i] << (8 * i);
|
|
+ *val |= (uint64_t)buf[i] << (8 * i);
|
|
|
|
kfree(buf);
|
|
|