From patchwork Mon Jan 25 14:07:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?C=C3=A9dric_Le_Goater?= X-Patchwork-Id: 8108931 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 0BFD2BEEE5 for ; Mon, 25 Jan 2016 14:12:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 69A6B202F8 for ; Mon, 25 Jan 2016 14:12:24 +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 ACC1420265 for ; Mon, 25 Jan 2016 14:12:23 +0000 (UTC) Received: from localhost ([::1]:38818 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aNhsU-0002wY-VO for patchwork-qemu-devel@patchwork.kernel.org; Mon, 25 Jan 2016 09:12:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37083) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aNhoh-0004ie-0a for qemu-devel@nongnu.org; Mon, 25 Jan 2016 09:08:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aNhod-0007Dq-PD for qemu-devel@nongnu.org; Mon, 25 Jan 2016 09:08:26 -0500 Received: from e06smtp15.uk.ibm.com ([195.75.94.111]:39292) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aNhod-0007Db-Go for qemu-devel@nongnu.org; Mon, 25 Jan 2016 09:08:23 -0500 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 25 Jan 2016 14:08:22 -0000 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 25 Jan 2016 14:08:12 -0000 X-IBM-Helo: d06dlp02.portsmouth.uk.ibm.com X-IBM-MailFrom: clg@fr.ibm.com X-IBM-RcptTo: qemu-devel@nongnu.org Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id CD83A2190023 for ; Mon, 25 Jan 2016 14:07:59 +0000 (GMT) Received: from d06av10.portsmouth.uk.ibm.com (d06av10.portsmouth.uk.ibm.com [9.149.37.251]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u0PE8CSk9240864 for ; Mon, 25 Jan 2016 14:08:12 GMT Received: from d06av10.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u0PD8DMr002669 for ; Mon, 25 Jan 2016 06:08:13 -0700 Received: from hermes.lab.toulouse-stg.fr.ibm.com (hermes.lab.toulouse-stg.fr.ibm.com [9.101.4.42]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u0PD7tNA001182; Mon, 25 Jan 2016 06:08:12 -0700 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: Corey Minyard Date: Mon, 25 Jan 2016 15:07:30 +0100 Message-Id: <1453730855-29302-6-git-send-email-clg@fr.ibm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1453730855-29302-1-git-send-email-clg@fr.ibm.com> References: <1453730855-29302-1-git-send-email-clg@fr.ibm.com> MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16012514-0021-0000-0000-00001FEDFEFF X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.111 Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Greg Kurz , qemu-devel@nongnu.org, "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCH v3 05/10] 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 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 --- Changes since v2: - the patch does not use the struct ipmi_sdr_header anymore as it was moved the patch forward in the patchset 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 2c540c0782c9..dee2190ce059 100644 --- a/hw/ipmi/ipmi_bmc_sim.c +++ b/hw/ipmi/ipmi_bmc_sim.c @@ -358,7 +358,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) { @@ -1166,7 +1166,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; } @@ -1175,7 +1175,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) { @@ -1649,17 +1649,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);