[openwrt/openwrt] bcm53xx: backport brcm_nvram changes needed for fix patch
LEDE Commits
lede-commits at lists.infradead.org
Thu Jan 18 08:13:15 PST 2024
rmilecki pushed a commit to openwrt/openwrt.git, branch openwrt-22.03:
https://git.openwrt.org/41e961c6f0026189642183f1c2002f913c2bbaf5
commit 41e961c6f0026189642183f1c2002f913c2bbaf5
Author: Rafał Miłecki <rafal at milecki.pl>
AuthorDate: Thu Jan 18 10:26:36 2024 +0100
bcm53xx: backport brcm_nvram changes needed for fix patch
Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
---
...nvram-Use-kzalloc-for-allocating-only-one.patch | 29 +++++++++++++++++++++
...02-nvmem-brcm_nvram-Add-check-for-kzalloc.patch | 30 ++++++++++++++++++++++
...nvram-Use-devm_platform_get_and_ioremap_r.patch | 30 ++++++++++++++++++++++
3 files changed, 89 insertions(+)
diff --git a/target/linux/bcm53xx/patches-5.10/083-v6.1-nvmem-brcm_nvram-Use-kzalloc-for-allocating-only-one.patch b/target/linux/bcm53xx/patches-5.10/083-v6.1-nvmem-brcm_nvram-Use-kzalloc-for-allocating-only-one.patch
new file mode 100644
index 0000000000..48ad63fab5
--- /dev/null
+++ b/target/linux/bcm53xx/patches-5.10/083-v6.1-nvmem-brcm_nvram-Use-kzalloc-for-allocating-only-one.patch
@@ -0,0 +1,29 @@
+From d3524bb5b9a0c567b853a0024526afe87dde01ed Mon Sep 17 00:00:00 2001
+From: Kenneth Lee <klee33 at uw.edu>
+Date: Fri, 16 Sep 2022 13:20:52 +0100
+Subject: [PATCH] nvmem: brcm_nvram: Use kzalloc for allocating only one
+ element
+
+Use kzalloc(...) rather than kcalloc(1, ...) because the number of
+elements we are specifying in this case is 1, so kzalloc would
+accomplish the same thing and we can simplify.
+
+Signed-off-by: Kenneth Lee <klee33 at uw.edu>
+Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla at linaro.org>
+Link: https://lore.kernel.org/r/20220916122100.170016-6-srinivas.kandagatla@linaro.org
+Signed-off-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
+---
+ drivers/nvmem/brcm_nvram.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/nvmem/brcm_nvram.c
++++ b/drivers/nvmem/brcm_nvram.c
+@@ -96,7 +96,7 @@ static int brcm_nvram_parse(struct brcm_
+
+ len = le32_to_cpu(header.len);
+
+- data = kcalloc(1, len, GFP_KERNEL);
++ data = kzalloc(len, GFP_KERNEL);
+ memcpy_fromio(data, priv->base, len);
+ data[len - 1] = '\0';
+
diff --git a/target/linux/bcm53xx/patches-5.10/084-v6.2-0002-nvmem-brcm_nvram-Add-check-for-kzalloc.patch b/target/linux/bcm53xx/patches-5.10/084-v6.2-0002-nvmem-brcm_nvram-Add-check-for-kzalloc.patch
new file mode 100644
index 0000000000..c37f8ff6f1
--- /dev/null
+++ b/target/linux/bcm53xx/patches-5.10/084-v6.2-0002-nvmem-brcm_nvram-Add-check-for-kzalloc.patch
@@ -0,0 +1,30 @@
+From b0576ade3aaf24b376ea1a4406ae138e2a22b0c0 Mon Sep 17 00:00:00 2001
+From: Jiasheng Jiang <jiasheng at iscas.ac.cn>
+Date: Fri, 27 Jan 2023 10:40:06 +0000
+Subject: [PATCH] nvmem: brcm_nvram: Add check for kzalloc
+
+Add the check for the return value of kzalloc in order to avoid
+NULL pointer dereference.
+
+Fixes: 6e977eaa8280 ("nvmem: brcm_nvram: parse NVRAM content into NVMEM cells")
+Cc: stable at vger.kernel.org
+Signed-off-by: Jiasheng Jiang <jiasheng at iscas.ac.cn>
+Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla at linaro.org>
+Link: https://lore.kernel.org/r/20230127104015.23839-2-srinivas.kandagatla@linaro.org
+Signed-off-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
+---
+ drivers/nvmem/brcm_nvram.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/drivers/nvmem/brcm_nvram.c
++++ b/drivers/nvmem/brcm_nvram.c
+@@ -98,6 +98,9 @@ static int brcm_nvram_parse(struct brcm_
+ len = le32_to_cpu(header.len);
+
+ data = kzalloc(len, GFP_KERNEL);
++ if (!data)
++ return -ENOMEM;
++
+ memcpy_fromio(data, priv->base, len);
+ data[len - 1] = '\0';
+
diff --git a/target/linux/bcm53xx/patches-5.10/086-v6.6-nvmem-brcm_nvram-Use-devm_platform_get_and_ioremap_r.patch b/target/linux/bcm53xx/patches-5.10/086-v6.6-nvmem-brcm_nvram-Use-devm_platform_get_and_ioremap_r.patch
new file mode 100644
index 0000000000..6945038ae7
--- /dev/null
+++ b/target/linux/bcm53xx/patches-5.10/086-v6.6-nvmem-brcm_nvram-Use-devm_platform_get_and_ioremap_r.patch
@@ -0,0 +1,30 @@
+From cfadd0e7d9225566f320bc4dc716682be910be6c Mon Sep 17 00:00:00 2001
+From: Yangtao Li <frank.li at vivo.com>
+Date: Wed, 23 Aug 2023 14:27:25 +0100
+Subject: [PATCH] nvmem: brcm_nvram: Use
+ devm_platform_get_and_ioremap_resource()
+
+Convert platform_get_resource(), devm_ioremap_resource() to a single
+call to devm_platform_get_and_ioremap_resource(), as this is exactly
+what this function does.
+
+Signed-off-by: Yangtao Li <frank.li at vivo.com>
+Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla at linaro.org>
+Link: https://lore.kernel.org/r/20230823132744.350618-4-srinivas.kandagatla@linaro.org
+Signed-off-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
+---
+ drivers/nvmem/brcm_nvram.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+--- a/drivers/nvmem/brcm_nvram.c
++++ b/drivers/nvmem/brcm_nvram.c
+@@ -131,8 +131,7 @@ static int brcm_nvram_probe(struct platf
+ return -ENOMEM;
+ priv->dev = dev;
+
+- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+- priv->base = devm_ioremap_resource(dev, res);
++ priv->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
+ if (IS_ERR(priv->base))
+ return PTR_ERR(priv->base);
+
More information about the lede-commits
mailing list