public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH v2 1/2] ACPI video: Harden video bus adding.
       [not found] <20120301175600.4c00eed3@garik>
@ 2012-03-30  7:47 ` Len Brown
  2012-03-30 17:32   ` [RESEND PATCH " Igor Murzov
  0 siblings, 1 reply; 4+ messages in thread
From: Len Brown @ 2012-03-30  7:47 UTC (permalink / raw)
  To: Igor Murzov
  Cc: Zhang Rui, linux-acpi, Dmitry Torokhov, linux-kernel, Igor Murzov,
	Sergey V.

I like this patch, but it arrived with some kind of white-space
formatting issue.  can you resend as plain text, or as a text attachment?

thanks,
-Len


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

* [RESEND PATCH 1/2] ACPI video: Harden video bus adding.
  2012-03-30  7:47 ` [PATCH v2 1/2] ACPI video: Harden video bus adding Len Brown
@ 2012-03-30 17:32   ` Igor Murzov
  2012-03-30 17:32     ` [RESEND PATCH 2/2] ACPI video: Don't start video device until its associated input device has been allocated Igor Murzov
  2012-03-30 19:46     ` [RESEND PATCH 1/2] ACPI video: Harden video bus adding Len Brown
  0 siblings, 2 replies; 4+ messages in thread
From: Igor Murzov @ 2012-03-30 17:32 UTC (permalink / raw)
  To: Len Brown, Zhang Rui; +Cc: linux-acpi, Dmitry Torokhov, Sergey V., Igor Murzov

It is always better to check return values, so add some new checks and
correct existing ones.

v2: Be consistent and don't mix errors from -E* and AE_* namespaces.

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

diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index eaef02a..fdb4b7d 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -548,27 +548,27 @@ acpi_video_device_EDID(struct acpi_video_device *device,
  *		1. 	The system BIOS should NOT automatically control the brightness 
  *			level of the LCD when the power changes from AC to DC.
  * Return Value:
- * 		-1	wrong arg.
+ * 		-EINVAL	wrong arg.
  */
 
 static int
 acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag)
 {
-	u64 status = 0;
+	acpi_status status;
 	union acpi_object arg0 = { ACPI_TYPE_INTEGER };
 	struct acpi_object_list args = { 1, &arg0 };
 
 
-	if (bios_flag < 0 || bios_flag > 3 || lcd_flag < 0 || lcd_flag > 1) {
-		status = -1;
-		goto Failed;
-	}
+	if (bios_flag < 0 || bios_flag > 3 || lcd_flag < 0 || lcd_flag > 1)
+		return -EINVAL;
 	arg0.integer.value = (lcd_flag << 2) | bios_flag;
 	video->dos_setting = arg0.integer.value;
-	acpi_evaluate_object(video->device->handle, "_DOS", &args, NULL);
+	status = acpi_evaluate_object(video->device->handle, "_DOS",
+	                              &args, NULL);
+	if (ACPI_FAILURE(status))
+		return -EIO;
 
-      Failed:
-	return status;
+	return 0;
 }
 
 /*
@@ -1343,15 +1343,17 @@ static int
 acpi_video_bus_get_devices(struct acpi_video_bus *video,
 			   struct acpi_device *device)
 {
-	int status = 0;
+	int status;
 	struct acpi_device *dev;
 
-	acpi_video_device_enumerate(video);
+	status = acpi_video_device_enumerate(video);
+	if (status)
+		return status;
 
 	list_for_each_entry(dev, &device->children, node) {
 
 		status = acpi_video_bus_get_one_device(dev, video);
-		if (ACPI_FAILURE(status)) {
+		if (status) {
 			printk(KERN_WARNING PREFIX
 					"Can't attach device\n");
 			continue;
@@ -1653,8 +1655,12 @@ static int acpi_video_bus_add(struct acpi_device *device)
 	mutex_init(&video->device_list_lock);
 	INIT_LIST_HEAD(&video->video_device_list);
 
-	acpi_video_bus_get_devices(video, device);
-	acpi_video_bus_start_devices(video);
+	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) {
@@ -1692,14 +1698,19 @@ static int acpi_video_bus_add(struct acpi_device *device)
 
 	video->pm_nb.notifier_call = acpi_video_resume;
 	video->pm_nb.priority = 0;
-	register_pm_notifier(&video->pm_nb);
+	error = register_pm_notifier(&video->pm_nb);
+	if (error)
+		goto err_unregister_input_dev;
 
 	return 0;
 
+ 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_put_video:
 	acpi_video_bus_put_devices(video);
 	kfree(video->attached_array);
  err_free_video:
-- 
1.7.5.1


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

* [RESEND PATCH 2/2] ACPI video: Don't start video device until its associated input device has been allocated
  2012-03-30 17:32   ` [RESEND PATCH " Igor Murzov
@ 2012-03-30 17:32     ` Igor Murzov
  2012-03-30 19:46     ` [RESEND PATCH 1/2] ACPI video: Harden video bus adding Len Brown
  1 sibling, 0 replies; 4+ messages in thread
From: Igor Murzov @ 2012-03-30 17:32 UTC (permalink / raw)
  To: Len Brown, Zhang Rui; +Cc: linux-acpi, Dmitry Torokhov, Sergey V., Igor Murzov

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


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

* Re: [RESEND PATCH 1/2] ACPI video: Harden video bus adding.
  2012-03-30 17:32   ` [RESEND PATCH " Igor Murzov
  2012-03-30 17:32     ` [RESEND PATCH 2/2] ACPI video: Don't start video device until its associated input device has been allocated Igor Murzov
@ 2012-03-30 19:46     ` Len Brown
  1 sibling, 0 replies; 4+ messages in thread
From: Len Brown @ 2012-03-30 19:46 UTC (permalink / raw)
  To: Igor Murzov
  Cc: Zhang Rui, linux-acpi, Dmitry Torokhov, Sergey V., Igor Murzov


Thanks for the re-send, Igor.

dos2unix was needed on the message, but I'm used to that...
In the future, please run checkpatch.pl on your patches before sending
them, as there were a couple of additional whitespace issues.

thanks,
Len Brown, Intel Open Source Technology Center


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

end of thread, other threads:[~2012-03-30 19:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [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     ` [RESEND PATCH 2/2] ACPI video: Don't start video device until its associated input device has been allocated Igor Murzov
2012-03-30 19:46     ` [RESEND PATCH 1/2] ACPI video: Harden video bus adding Len Brown

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