public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] isa: Prevent NULL dereference in isa_bus driver callbacks
@ 2017-11-08 15:23 William Breathitt Gray
  2017-11-08 17:11 ` Linus Torvalds
  0 siblings, 1 reply; 3+ messages in thread
From: William Breathitt Gray @ 2017-11-08 15:23 UTC (permalink / raw)
  To: gregkh; +Cc: fengguang.wu, torvalds, linux-kernel, William Breathitt Gray

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: a5117ba7da37 ("[PATCH] Driver model: add ISA bus")
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
---
 drivers/base/isa.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/base/isa.c b/drivers/base/isa.c
index cd6ccdcf9df0..372d10af2600 100644
--- a/drivers/base/isa.c
+++ b/drivers/base/isa.c
@@ -39,7 +39,7 @@ static int isa_bus_probe(struct device *dev)
 {
 	struct isa_driver *isa_driver = dev->platform_data;
 
-	if (isa_driver->probe)
+	if (isa_driver && isa_driver->probe)
 		return isa_driver->probe(dev, to_isa_dev(dev)->id);
 
 	return 0;
@@ -49,7 +49,7 @@ static int isa_bus_remove(struct device *dev)
 {
 	struct isa_driver *isa_driver = dev->platform_data;
 
-	if (isa_driver->remove)
+	if (isa_driver && isa_driver->remove)
 		return isa_driver->remove(dev, to_isa_dev(dev)->id);
 
 	return 0;
@@ -59,7 +59,7 @@ static void isa_bus_shutdown(struct device *dev)
 {
 	struct isa_driver *isa_driver = dev->platform_data;
 
-	if (isa_driver->shutdown)
+	if (isa_driver && isa_driver->shutdown)
 		isa_driver->shutdown(dev, to_isa_dev(dev)->id);
 }
 
@@ -67,7 +67,7 @@ static int isa_bus_suspend(struct device *dev, pm_message_t state)
 {
 	struct isa_driver *isa_driver = dev->platform_data;
 
-	if (isa_driver->suspend)
+	if (isa_driver && isa_driver->suspend)
 		return isa_driver->suspend(dev, to_isa_dev(dev)->id, state);
 
 	return 0;
@@ -77,7 +77,7 @@ static int isa_bus_resume(struct device *dev)
 {
 	struct isa_driver *isa_driver = dev->platform_data;
 
-	if (isa_driver->resume)
+	if (isa_driver && isa_driver->resume)
 		return isa_driver->resume(dev, to_isa_dev(dev)->id);
 
 	return 0;
-- 
2.15.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] isa: Prevent NULL dereference in isa_bus driver callbacks
  2017-11-08 15:23 [PATCH] isa: Prevent NULL dereference in isa_bus driver callbacks William Breathitt Gray
@ 2017-11-08 17:11 ` Linus Torvalds
  2017-11-08 18:12   ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Torvalds @ 2017-11-08 17:11 UTC (permalink / raw)
  To: William Breathitt Gray
  Cc: Greg Kroah-Hartman, Wu Fengguang, Linux Kernel Mailing List

On Wed, Nov 8, 2017 at 7:23 AM, William Breathitt Gray
<vilhelm.gray@gmail.com> wrote:
>
> 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.

Thanks. Acked-by: Linus Torvalds <torvalds@linux-foundation.org>

And it doesn't seem critical enough for me to take directly this late
in the 4.14 game, so I guess I'll get it from the usual channels.

          Linus

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] isa: Prevent NULL dereference in isa_bus driver callbacks
  2017-11-08 17:11 ` Linus Torvalds
@ 2017-11-08 18:12   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2017-11-08 18:12 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: William Breathitt Gray, Wu Fengguang, Linux Kernel Mailing List

On Wed, Nov 08, 2017 at 09:11:22AM -0800, Linus Torvalds wrote:
> On Wed, Nov 8, 2017 at 7:23 AM, William Breathitt Gray
> <vilhelm.gray@gmail.com> wrote:
> >
> > 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.
> 
> Thanks. Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
> 
> And it doesn't seem critical enough for me to take directly this late
> in the 4.14 game, so I guess I'll get it from the usual channels.

I'll queue it up, given that this has been a problem for 10+ years :)

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-11-08 18:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-08 15:23 [PATCH] isa: Prevent NULL dereference in isa_bus driver callbacks William Breathitt Gray
2017-11-08 17:11 ` Linus Torvalds
2017-11-08 18:12   ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox