Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

misc: sram: fix check of devm_ioremap*() return value

Both devm_ioremap() and devm_ioremap_wc() functions return either
a pointer to valid iomem region or NULL, check for IS_ERR() is improper
and may result in oops on error path. Now on error -ENOMEM is returned.

Fixes: 0ab163ad1ea0 ("misc: sram: switch to ioremap_wc from ioremap")
Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Vladimir Zapolskiy and committed by
Greg Kroah-Hartman
d449d69d 47f55b74

+2 -2
+2 -2
drivers/misc/sram.c
··· 364 364 sram->virt_base = devm_ioremap(sram->dev, res->start, size); 365 365 else 366 366 sram->virt_base = devm_ioremap_wc(sram->dev, res->start, size); 367 - if (IS_ERR(sram->virt_base)) 368 - return PTR_ERR(sram->virt_base); 367 + if (!sram->virt_base) 368 + return -ENOMEM; 369 369 370 370 sram->pool = devm_gen_pool_create(sram->dev, ilog2(SRAM_GRANULARITY), 371 371 NUMA_NO_NODE, NULL);