* [PATCH -next] nvmem: Fix return value check in rmem_read()
@ 2021-02-23 14:22 Wei Yongjun
2021-02-23 14:55 ` Nicolas Saenz Julienne
0 siblings, 1 reply; 2+ messages in thread
From: Wei Yongjun @ 2021-02-23 14:22 UTC (permalink / raw)
To: Hulk Robot, Srinivas Kandagatla, Nicolas Saenz Julienne
Cc: Wei Yongjun, linux-kernel
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")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
drivers/nvmem/rmem.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/nvmem/rmem.c b/drivers/nvmem/rmem.c
index b11c3c974b3d..80cb187f1481 100644
--- a/drivers/nvmem/rmem.c
+++ b/drivers/nvmem/rmem.c
@@ -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);
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH -next] nvmem: Fix return value check in rmem_read()
2021-02-23 14:22 [PATCH -next] nvmem: Fix return value check in rmem_read() Wei Yongjun
@ 2021-02-23 14:55 ` Nicolas Saenz Julienne
0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Saenz Julienne @ 2021-02-23 14:55 UTC (permalink / raw)
To: Wei Yongjun, Hulk Robot, Srinivas Kandagatla; +Cc: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 490 bytes --]
On Tue, 2021-02-23 at 14:22 +0000, Wei Yongjun wrote:
> 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")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> ---
Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Thanks!
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-02-23 14:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-23 14:22 [PATCH -next] nvmem: Fix return value check in rmem_read() Wei Yongjun
2021-02-23 14:55 ` Nicolas Saenz Julienne
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).