From mboxrd@z Thu Jan 1 00:00:00 1970 From: Richard Henderson Subject: Re: [Qemu-devel] [RFC PATCH 7/7] acpi: fix bug in acpi_checksum() caused by garbage in checksum field Date: Tue, 30 Mar 2010 08:10:52 -0700 Message-ID: <4BB2147C.9010506@twiddle.net> References: <7498607873ad7c9ff59d0a24d35391c0e4ba0a11.1269936879.git.eduard.munteanu@linux360.ro> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: joro@8bytes.org, aliguori@us.ibm.com, avi@redhat.com, kvm@vger.kernel.org, qemu-devel@nongnu.org To: Eduard - Gabriel Munteanu Return-path: Received: from are.twiddle.net ([75.149.56.221]:54646 "EHLO are.twiddle.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754163Ab0C3PKx (ORCPT ); Tue, 30 Mar 2010 11:10:53 -0400 In-Reply-To: <7498607873ad7c9ff59d0a24d35391c0e4ba0a11.1269936879.git.eduard.munteanu@linux360.ro> Sender: kvm-owner@vger.kernel.org List-ID: On 03/30/2010 01:20 AM, Eduard - Gabriel Munteanu wrote: > + /* Ignore preexisting garbage in checksum. */ > + acpi_hdr = (struct acpi_table_header *) data; > + sum -= acpi_hdr->checksum; > + > return (-sum) & 0xff; Wouldn't it be cleaner to adjust the acpi_checksum definition to take and acpi_table_header operand instead of uint8_t? And given it's only usage, perhaps update the checksum instead of returning it? E.g. - ((struct acpi_table_header*)p)->checksum = acpi_checksum((uint8_t*)p, off); + acpi_update_checksum((struct acpi_table_header *)p, off); r~ From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nwd5o-0003qO-LV for qemu-devel@nongnu.org; Tue, 30 Mar 2010 11:11:00 -0400 Received: from [140.186.70.92] (port=48981 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nwd5n-0003pq-E8 for qemu-devel@nongnu.org; Tue, 30 Mar 2010 11:11:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Nwd5j-0007qq-8P for qemu-devel@nongnu.org; Tue, 30 Mar 2010 11:10:59 -0400 Received: from are.twiddle.net ([75.149.56.221]:54754) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nwd5j-0007qW-2n for qemu-devel@nongnu.org; Tue, 30 Mar 2010 11:10:55 -0400 Message-ID: <4BB2147C.9010506@twiddle.net> Date: Tue, 30 Mar 2010 08:10:52 -0700 From: Richard Henderson MIME-Version: 1.0 Subject: Re: [Qemu-devel] [RFC PATCH 7/7] acpi: fix bug in acpi_checksum() caused by garbage in checksum field References: <7498607873ad7c9ff59d0a24d35391c0e4ba0a11.1269936879.git.eduard.munteanu@linux360.ro> In-Reply-To: <7498607873ad7c9ff59d0a24d35391c0e4ba0a11.1269936879.git.eduard.munteanu@linux360.ro> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduard - Gabriel Munteanu Cc: qemu-devel@nongnu.org, joro@8bytes.org, aliguori@us.ibm.com, kvm@vger.kernel.org, avi@redhat.com On 03/30/2010 01:20 AM, Eduard - Gabriel Munteanu wrote: > + /* Ignore preexisting garbage in checksum. */ > + acpi_hdr = (struct acpi_table_header *) data; > + sum -= acpi_hdr->checksum; > + > return (-sum) & 0xff; Wouldn't it be cleaner to adjust the acpi_checksum definition to take and acpi_table_header operand instead of uint8_t? And given it's only usage, perhaps update the checksum instead of returning it? E.g. - ((struct acpi_table_header*)p)->checksum = acpi_checksum((uint8_t*)p, off); + acpi_update_checksum((struct acpi_table_header *)p, off); r~