All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Len Brown <len.brown@intel.com>
Cc: Zhang Rui <rui.zhang@intel.com>, linux-acpi@vger.kernel.org
Subject: [PATCH 2/4] ACPI: video - fix potential crash when unloading
Date: Sat, 08 Aug 2009 00:26:25 -0700	[thread overview]
Message-ID: <20090808075636.C8B31526EC9@mailhub.coreip.homeip.net> (raw)
In-Reply-To: <20090808072150.2980.3863.stgit@localhost.localdomain>

thermal_cooling_device_register() returns error encoded in a pointer
when it fails in which case we need to explictly set device->cdev
to NULL so we don't try to unregister it when unloading.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/acpi/video.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index d8e64cf..98ade4e 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -992,8 +992,18 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
 
 		device->cdev = thermal_cooling_device_register("LCD",
 					device->dev, &video_cooling_ops);
-		if (IS_ERR(device->cdev))
+		if (IS_ERR(device->cdev)) {
+			/*
+			 * Set cdev to NULL so we don't crash trying to
+			 * free it.
+			 * Also, why the hell we are returnign early and
+			 * not attempt to register video output if cooling
+			 * device registration failed?
+			 * -- dtor
+			 */
+			device->cdev = NULL;
 			return;
+		}
 
 		dev_info(&device->dev->dev, "registered as cooling_device%d\n",
 			 device->cdev->id);


  parent reply	other threads:[~2009-08-08  7:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20090808072150.2980.3863.stgit@localhost.localdomain>
2009-08-08  7:26 ` [PATCH 1/4] ACPI: video - fix oops when unloading module Dmitry Torokhov
2009-08-10  1:31   ` Zhang Rui
2009-08-30  2:55     ` Len Brown
2009-08-08  7:26 ` Dmitry Torokhov [this message]
2009-08-10  2:11   ` [PATCH 2/4] ACPI: video - fix potential crash when unloading Zhang Rui
2009-08-30  2:59     ` Len Brown
2009-08-08  7:26 ` [PATCH 3/4] ACPI: video - rename cdev to cooling_device Dmitry Torokhov
2009-08-30  3:04   ` Len Brown
2009-08-08  7:26 ` [PATCH 4/4] ACPI: video - cleanup video device registration Dmitry Torokhov
2009-08-10  2:11   ` Zhang Rui
2009-08-10  5:51     ` Dmitry Torokhov
2009-08-10  6:21       ` Zhang Rui
2009-08-30  3:24   ` Len Brown
2009-09-01  6:30     ` Dmitry Torokhov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090808075636.C8B31526EC9@mailhub.coreip.homeip.net \
    --to=dmitry.torokhov@gmail.com \
    --cc=len.brown@intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=rui.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.