From patchwork Thu Oct 1 22:51:39 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arjan van de Ven X-Patchwork-Id: 51045 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n91Ms4YQ016590 for ; Thu, 1 Oct 2009 22:54:04 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754037AbZJAWvo (ORCPT ); Thu, 1 Oct 2009 18:51:44 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754323AbZJAWvn (ORCPT ); Thu, 1 Oct 2009 18:51:43 -0400 Received: from casper.infradead.org ([85.118.1.10]:41076 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754230AbZJAWvS convert rfc822-to-8bit (ORCPT ); Thu, 1 Oct 2009 18:51:18 -0400 Received: from c-24-20-218-92.hsd1.or.comcast.net ([24.20.218.92] helo=localhost.localdomain) by casper.infradead.org with esmtpsa (Exim 4.69 #1 (Red Hat Linux)) id 1MtUUZ-0007nu-SU; Thu, 01 Oct 2009 22:51:20 +0000 Date: Thu, 1 Oct 2009 15:51:39 -0700 From: Arjan van de Ven To: len.brown@intel.com Cc: linux-acpi@vger.kernel.org, akpm@linux-foundation.org Subject: [PATCH] acpi: clean up video.c boundary checks and types Message-ID: <20091001155139.3b9de603@infradead.org> Organization: Intel X-Mailer: Claws Mail 3.7.2 (GTK+ 2.16.6; i586-redhat-linux-gnu) Mime-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org See http://www.infradead.org/rpr.html Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org diff --git a/drivers/acpi/proc.c b/drivers/acpi/proc.c index d0d550d..ceff3ad 100644 --- a/drivers/acpi/proc.c +++ b/drivers/acpi/proc.c @@ -393,7 +393,7 @@ acpi_system_write_wakeup_device(struct file *file, struct list_head *node, *next; char strbuf[5]; char str[5] = ""; - int len = count; + unsigned int len = count; struct acpi_device *found_dev = NULL; if (len > 4) diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index a4fddb2..2868303 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -1218,7 +1218,7 @@ acpi_video_device_write_state(struct file *file, u32 state = 0; - if (!dev || count + 1 > sizeof str) + if (!dev || count >= sizeof(str)) return -EINVAL; if (copy_from_user(str, buffer, count)) @@ -1275,7 +1275,7 @@ acpi_video_device_write_brightness(struct file *file, int i; - if (!dev || !dev->brightness || count + 1 > sizeof str) + if (!dev || !dev->brightness || count >= sizeof(str)) return -EINVAL; if (copy_from_user(str, buffer, count)) @@ -1557,7 +1557,7 @@ acpi_video_bus_write_POST(struct file *file, unsigned long long opt, options; - if (!video || count + 1 > sizeof str) + if (!video || count >= sizeof(str)) return -EINVAL; status = acpi_video_bus_POST_options(video, &options); @@ -1597,7 +1597,7 @@ acpi_video_bus_write_DOS(struct file *file, unsigned long opt; - if (!video || count + 1 > sizeof str) + if (!video || count >= sizeof(str)) return -EINVAL; if (copy_from_user(str, buffer, count))