Skip to content

Commit 5a24472

Browse files
William Breathitt Graygregkh
authored andcommitted
isa: Prevent NULL dereference in isa_bus driver callbacks
The isa_driver structure for an isa_bus device is stored in the device platform_data member of the respective device structure. This platform_data member may be reset to NULL if isa_driver match callback for the device fails, indicating a device unsupported by the ISA driver. This patch fixes a possible NULL pointer dereference if one of the isa_driver callbacks to attempted for an unsupported device. This error should not occur in practice since ISA devices are typically manually configured and loaded by the users, but we may as well prevent this error from popping up for the 0day testers. Fixes: a5117ba ("[PATCH] Driver model: add ISA bus") Signed-off-by: William Breathitt Gray <[email protected]> Cc: stable <[email protected]> Acked-by: Linus Torvalds <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent f50caa9 commit 5a24472

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/base/isa.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static int isa_bus_probe(struct device *dev)
3939
{
4040
struct isa_driver *isa_driver = dev->platform_data;
4141

42-
if (isa_driver->probe)
42+
if (isa_driver && isa_driver->probe)
4343
return isa_driver->probe(dev, to_isa_dev(dev)->id);
4444

4545
return 0;
@@ -49,7 +49,7 @@ static int isa_bus_remove(struct device *dev)
4949
{
5050
struct isa_driver *isa_driver = dev->platform_data;
5151

52-
if (isa_driver->remove)
52+
if (isa_driver && isa_driver->remove)
5353
return isa_driver->remove(dev, to_isa_dev(dev)->id);
5454

5555
return 0;
@@ -59,15 +59,15 @@ static void isa_bus_shutdown(struct device *dev)
5959
{
6060
struct isa_driver *isa_driver = dev->platform_data;
6161

62-
if (isa_driver->shutdown)
62+
if (isa_driver && isa_driver->shutdown)
6363
isa_driver->shutdown(dev, to_isa_dev(dev)->id);
6464
}
6565

6666
static int isa_bus_suspend(struct device *dev, pm_message_t state)
6767
{
6868
struct isa_driver *isa_driver = dev->platform_data;
6969

70-
if (isa_driver->suspend)
70+
if (isa_driver && isa_driver->suspend)
7171
return isa_driver->suspend(dev, to_isa_dev(dev)->id, state);
7272

7373
return 0;
@@ -77,7 +77,7 @@ static int isa_bus_resume(struct device *dev)
7777
{
7878
struct isa_driver *isa_driver = dev->platform_data;
7979

80-
if (isa_driver->resume)
80+
if (isa_driver && isa_driver->resume)
8181
return isa_driver->resume(dev, to_isa_dev(dev)->id);
8282

8383
return 0;

0 commit comments

Comments
 (0)