mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
misc: pvpanic: Check devm_ioport_map() for NULL
Inconveniently devm_ioport_map() and devm_ioremap_resource()
return errors differently, i.e. former uses simply NULL pointer,
while the latter an error pointer.
Due to this, we have to check each of them separately.
Fixes: f104060813
("misc: pvpanic: Combine ACPI and platform drivers")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20201228184313.57610-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
b8b54ad96e
commit
afded6d83a
1 changed files with 15 additions and 4 deletions
|
@ -55,12 +55,23 @@ static int pvpanic_mmio_probe(struct platform_device *pdev)
|
||||||
struct resource *res;
|
struct resource *res;
|
||||||
|
|
||||||
res = platform_get_mem_or_io(pdev, 0);
|
res = platform_get_mem_or_io(pdev, 0);
|
||||||
if (res && resource_type(res) == IORESOURCE_IO)
|
if (!res)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
switch (resource_type(res)) {
|
||||||
|
case IORESOURCE_IO:
|
||||||
base = devm_ioport_map(dev, res->start, resource_size(res));
|
base = devm_ioport_map(dev, res->start, resource_size(res));
|
||||||
else
|
if (!base)
|
||||||
|
return -ENOMEM;
|
||||||
|
break;
|
||||||
|
case IORESOURCE_MEM:
|
||||||
base = devm_ioremap_resource(dev, res);
|
base = devm_ioremap_resource(dev, res);
|
||||||
if (IS_ERR(base))
|
if (IS_ERR(base))
|
||||||
return PTR_ERR(base);
|
return PTR_ERR(base);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
atomic_notifier_chain_register(&panic_notifier_list,
|
atomic_notifier_chain_register(&panic_notifier_list,
|
||||||
&pvpanic_panic_nb);
|
&pvpanic_panic_nb);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue