Skip to content

Commit afded6d

Browse files
andy-shevgregkh
authored andcommitted
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: f104060 ("misc: pvpanic: Combine ACPI and platform drivers") Signed-off-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent b8b54ad commit afded6d

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

drivers/misc/pvpanic.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,23 @@ static int pvpanic_mmio_probe(struct platform_device *pdev)
5555
struct resource *res;
5656

5757
res = platform_get_mem_or_io(pdev, 0);
58-
if (res && resource_type(res) == IORESOURCE_IO)
58+
if (!res)
59+
return -EINVAL;
60+
61+
switch (resource_type(res)) {
62+
case IORESOURCE_IO:
5963
base = devm_ioport_map(dev, res->start, resource_size(res));
60-
else
64+
if (!base)
65+
return -ENOMEM;
66+
break;
67+
case IORESOURCE_MEM:
6168
base = devm_ioremap_resource(dev, res);
62-
if (IS_ERR(base))
63-
return PTR_ERR(base);
69+
if (IS_ERR(base))
70+
return PTR_ERR(base);
71+
break;
72+
default:
73+
return -EINVAL;
74+
}
6475

6576
atomic_notifier_chain_register(&panic_notifier_list,
6677
&pvpanic_panic_nb);

0 commit comments

Comments
 (0)