All of lore.kernel.org
 help / color / mirror / Atom feed
From: Igor Murzov <intergalactic.anonymous@gmail.com>
To: Len Brown <lenb@kernel.org>, Zhang Rui <rui.zhang@intel.com>
Cc: linux-acpi@vger.kernel.org,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	"Sergey V." <sftp.mtuci@gmail.com>, Igor Murzov <e-mail@date.by>
Subject: [RESEND PATCH 2/2] ACPI video: Don't start video device until its associated input device has been allocated
Date: Fri, 30 Mar 2012 21:32:09 +0400	[thread overview]
Message-ID: <1333128729-19844-2-git-send-email-e-mail@date.by> (raw)
In-Reply-To: <1333128729-19844-1-git-send-email-e-mail@date.by>

Quoth Dmitry Torokhov:
In addition to bus notifier we do install device notifier explicitly
so it might fire up early. The easiest fox would be to move
acpi_video_bus_start_devices() after input_allocate_device() but
before input_register_device() - unregistered input devices can handle
input_event() calls just fine.

May fix crashes reported in:
https://bugzilla.kernel.org/show_bug.cgi?id=40672

Signed-off-by: Igor Murzov <e-mail@date.by>
---
 drivers/acpi/video.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index fdb4b7d..e70036c 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -1658,16 +1658,17 @@ static int acpi_video_bus_add(struct acpi_device *device)
 	error = acpi_video_bus_get_devices(video, device);
 	if (error)
 		goto err_free_video;
-	error = acpi_video_bus_start_devices(video);
-	if (error)
-		goto err_put_video;
 
 	video->input = input = input_allocate_device();
 	if (!input) {
 		error = -ENOMEM;
-		goto err_stop_video;
+		goto err_put_video;
 	}
 
+	error = acpi_video_bus_start_devices(video);
+	if (error)
+		goto err_free_input_dev;
+
 	snprintf(video->phys, sizeof(video->phys),
 		"%s/video/input0", acpi_device_hid(video->device));
 
@@ -1688,7 +1689,7 @@ static int acpi_video_bus_add(struct acpi_device *device)
 
 	error = input_register_device(input);
 	if (error)
-		goto err_free_input_dev;
+		goto err_stop_video;
 
 	printk(KERN_INFO PREFIX "%s [%s] (multi-head: %s  rom: %s  post: %s)\n",
 	       ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device),
@@ -1706,10 +1707,10 @@ static int acpi_video_bus_add(struct acpi_device *device)
 
  err_unregister_input_dev:
 	input_unregister_device(input);
- err_free_input_dev:
-	input_free_device(input);
  err_stop_video:
 	acpi_video_bus_stop_devices(video);
+ err_free_input_dev:
+	input_free_device(input);
  err_put_video:
 	acpi_video_bus_put_devices(video);
 	kfree(video->attached_array);
-- 
1.7.5.1


  reply	other threads:[~2012-03-30 17:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20120301175600.4c00eed3@garik>
2012-03-30  7:47 ` [PATCH v2 1/2] ACPI video: Harden video bus adding Len Brown
2012-03-30 17:32   ` [RESEND PATCH " Igor Murzov
2012-03-30 17:32     ` Igor Murzov [this message]
2012-03-30 19:46     ` Len Brown

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=1333128729-19844-2-git-send-email-e-mail@date.by \
    --to=intergalactic.anonymous@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=e-mail@date.by \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=sftp.mtuci@gmail.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.