From patchwork Sat Feb 6 19:13:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 8243411 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E483EBEEE5 for ; Sat, 6 Feb 2016 19:29:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4BD6220260 for ; Sat, 6 Feb 2016 19:29:49 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8F0C4201BC for ; Sat, 6 Feb 2016 19:29:48 +0000 (UTC) Received: from localhost ([::1]:56215 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aS8YF-0006kU-UA for patchwork-qemu-devel@patchwork.kernel.org; Sat, 06 Feb 2016 14:29:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53235) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aS8Ic-0002XC-JT for qemu-devel@nongnu.org; Sat, 06 Feb 2016 14:13:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aS8Ib-0002Tr-7W for qemu-devel@nongnu.org; Sat, 06 Feb 2016 14:13:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56440) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aS8Ib-0002Tn-03 for qemu-devel@nongnu.org; Sat, 06 Feb 2016 14:13:37 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id B12253B70B; Sat, 6 Feb 2016 19:13:36 +0000 (UTC) Received: from redhat.com (vpn1-5-159.ams2.redhat.com [10.36.5.159]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u16JDXg9016218; Sat, 6 Feb 2016 14:13:34 -0500 Date: Sat, 6 Feb 2016 21:13:33 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1454784308-21177-22-git-send-email-mst@redhat.com> References: <1454784308-21177-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1454784308-21177-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Peter Maydell , =?us-ascii?B?PT9VVEYtOD9xP0M9QzM9QTlkcmljPTIwTGU9MjBHb2F0ZXI/PQ==?= , Eduardo Habkost , Greg Kurz , Corey Minyard Subject: [Qemu-devel] [PULL v2 21/45] ipmi: fix SDR length value X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Cédric Le Goater The IPMI BMC simulator populates the SDR table with a set of initial SDRs. The length of each SDR is taken from the record itself (byte 4) which does not include the size of the header. But, the full length (header + data) is required by the sdr_add_entry() routine. Signed-off-by: Cédric Le Goater Acked-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/ipmi/ipmi_bmc_sim.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c index d8ca76a..73a4f6a 100644 --- a/hw/ipmi/ipmi_bmc_sim.c +++ b/hw/ipmi/ipmi_bmc_sim.c @@ -356,7 +356,7 @@ static int sdr_find_entry(IPMISdr *sdr, uint16_t recid, while (pos < sdr->next_free) { uint16_t trec = sdr->sdr[pos] | (sdr->sdr[pos + 1] << 8); - unsigned int nextpos = pos + sdr->sdr[pos + 4]; + unsigned int nextpos = pos + sdr->sdr[pos + 4] + 5; if (trec == recid) { if (nextrec) { @@ -1164,7 +1164,7 @@ static void get_sdr(IPMIBmcSim *ibs, rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT; return; } - if (cmd[6] > (ibs->sdr.sdr[pos + 4])) { + if (cmd[6] > (ibs->sdr.sdr[pos + 4] + 5)) { rsp[2] = IPMI_CC_PARM_OUT_OF_RANGE; return; } @@ -1173,7 +1173,7 @@ static void get_sdr(IPMIBmcSim *ibs, IPMI_ADD_RSP_DATA((nextrec >> 8) & 0xff); if (cmd[7] == 0xff) { - cmd[7] = ibs->sdr.sdr[pos + 4] - cmd[6]; + cmd[7] = ibs->sdr.sdr[pos + 4] + 5 - cmd[6]; } if ((cmd[7] + *rsp_len) > max_rsp_len) { @@ -1647,17 +1647,17 @@ static void ipmi_sim_init(Object *obj) error_report("Problem with recid 0x%4.4x", i); return; } - len = init_sdrs[i + 4]; + len = init_sdrs[i + 4] + 5; recid = init_sdrs[i] | (init_sdrs[i + 1] << 8); if (recid == 0xffff) { break; } - if ((i + len + 5) > sizeof(init_sdrs)) { + if ((i + len) > sizeof(init_sdrs)) { error_report("Problem with recid 0x%4.4x", i); return; } sdr_add_entry(ibs, init_sdrs + i, len, NULL); - i += len + 5; + i += len; } ipmi_init_sensors_from_sdrs(ibs);