nvmem: rmem: Fix return value check in rmem_read()

[ Upstream commit 58e92c4a49 ]

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: 5a3fa75a4d ("nvmem: Add driver to expose reserved memory as nvmem")
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20221118063840.6357-3-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Wei Yongjun 2022-11-18 06:38:38 +00:00 коммит произвёл Greg Kroah-Hartman
Родитель e376183167
Коммит 36164db278
1 изменённых файлов: 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. * but as of Dec 2020 this isn't possible on arm64.
*/ */
addr = memremap(priv->mem->base, available, MEMREMAP_WB); addr = memremap(priv->mem->base, available, MEMREMAP_WB);
if (IS_ERR(addr)) { if (!addr) {
dev_err(priv->dev, "Failed to remap memory region\n"); 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); count = memory_read_from_buffer(val, bytes, &off, addr, available);