nvmem: Fix return value check in rmem_read()
PATCH RESEND 1/1 nvmem: Fix return value check in rmem_read()
From: Wei Yongjun <[email protected]>
In case of error, the function memremap() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test.
Fixes 5a3fa75a4d9c ("nvmem: Add driver to expose reserved memory as nvmem")
Cc Srinivas Kandagatla <[email protected]>
Cc Nicolas Saenz Julienne <[email protected]>
Signed-off-by Wei Yongjun <[email protected]>
Signed-off-by Yang Yingliang <[email protected]>
---
The previous patch link:
https://lore.kernel.org/all/[email protected]/T/
--- drivers/nvmem/rmem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/nvmem/rmem.c +2 -2
@@ -37,9 +37,9 @@ static int rmem_read(void *context, unsigned int offset,* but as of Dec 2020 this isn't possible on arm64. */ addr =memremap (priv->mem->base, available,MEMREMAP_WB ); -if (IS_ERR (addr)) { +if (!addr) {dev_err (priv->dev,"Failed to remap memory region\n" ); -return PTR_ERR (addr); +return -ENOMEM ; } count =memory_read_from_buffer (val, bytes, &off, addr, available);
Signature · 1 line
2.25.1
Quoted 12 lines · Yang Yingliang
From: Wei Yongjun <[email protected]>
In case of error, the function
memremap()returns NULL pointer notERR_PTR(). TheIS_ERR()test in the return value check should be replaced with NULL test.Fixes 5a3fa75a4d9c ("nvmem: Add driver to expose reserved memory as nvmem")Cc Srinivas Kandagatla <[email protected]>Cc Nicolas Saenz Julienne <[email protected]>Signed-off-by Wei Yongjun <[email protected]>Signed-off-by Yang Yingliang <[email protected]>
Quoted 4 lines
---
The previous patch link:
https://lore.kernel.org/all/[email protected]/T/
---
Applied thanks,
--srini
Quoted 19 lines
drivers/nvmem/rmem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/nvmem/rmem.c +2
-2@@ -37,9 +37,9 @@ static int rmem_read(void *context, unsigned int offset,* but as of Dec 2020 this isn't possible on arm64. */ addr =memremap (priv->mem->base, available,MEMREMAP_WB ); -if (IS_ERR (addr)) { +if (!addr) {dev_err (priv->dev,"Failed to remap memory region\n" ); -return PTR_ERR (addr); +return -ENOMEM ; } count =memory_read_from_buffer (val, bytes, &off, addr, available);