From: Rafał Miłecki Date: Thu, 18 Jan 2024 09:26:36 +0000 (+0100) Subject: bcm53xx: backport brcm_nvram changes needed for fix patch X-Git-Tag: v22.03.7~62 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=41e961c6f0026189642183f1c2002f913c2bbaf5;p=openwrt%2Fstaging%2Fpepe2k.git bcm53xx: backport brcm_nvram changes needed for fix patch Signed-off-by: Rafał Miłecki --- 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 +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 +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20220916122100.170016-6-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + 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 +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@vger.kernel.org +Signed-off-by: Jiasheng Jiang +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20230127104015.23839-2-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + 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 +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 +Signed-off-by: Srinivas Kandagatla +Link: https://lore.kernel.org/r/20230823132744.350618-4-srinivas.kandagatla@linaro.org +Signed-off-by: Greg Kroah-Hartman +--- + 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); +