From patchwork Thu Feb 28 18:17:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 10833595 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A76011575 for ; Thu, 28 Feb 2019 18:33:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9440D2A56E for ; Thu, 28 Feb 2019 18:33:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 921402F6DB; Thu, 28 Feb 2019 18:33:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3DA002F6C8 for ; Thu, 28 Feb 2019 18:33:09 +0000 (UTC) Received: from localhost ([127.0.0.1]:44706 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzQUW-0003gH-FI for patchwork-qemu-devel@patchwork.kernel.org; Thu, 28 Feb 2019 13:33:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzQFo-0000aF-B5 for qemu-devel@nongnu.org; Thu, 28 Feb 2019 13:18:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzQFc-0002Lu-Ns for qemu-devel@nongnu.org; Thu, 28 Feb 2019 13:17:56 -0500 Received: from mail-oi1-x231.google.com ([2607:f8b0:4864:20::231]:41540) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gzQFY-0002DG-BD for qemu-devel@nongnu.org; Thu, 28 Feb 2019 13:17:40 -0500 Received: by mail-oi1-x231.google.com with SMTP id e7so17274032oia.8 for ; Thu, 28 Feb 2019 10:17:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=UnkEe3Lz2kCnlXnA1sXksP9chMKTTYD82HqDl1kU840=; b=VvjMQKkq87dHE8JN6XudaB863L88/NbwejEehUfsicdMOnagefwJWLnaZGDDE2NrrB nXYekbKYAatT5TazulPi5p643eQo8zk9VsNIDoWZJcwHiQI4gw22txz+cAPsaC2Diiy6 LbPIJBb4h6fO5hANIOoNmXho9fRfrMnC6E2VuZKHPihQt6/O3W0tRSU5qXTmfFE81Vzv 7PABD1kZJhHv1joLSouC9bI4g85H0Etwpomvhdb1iVBPV0kwqRjWAy+G8OEu3TLyiS/f 5I93k138U0jPBu9PjnGPkObhYoiey9J8/jKkejAoWnIy+qn5l+JRh0/wdgXHNYocvsM8 LcpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=UnkEe3Lz2kCnlXnA1sXksP9chMKTTYD82HqDl1kU840=; b=ajCGx6XQkWS+3e6F8rrNJjd9xDPr2w6NOukSy5bm8dafU4smqGevl/WdIizHs/ZOMg TAYaLnWcPmklL2hfBxA0fgX+ppWsynPhsZWydlHPYoYiPFBrx7R4uPV3EutWlhl6+03Z JD/2Krtn9Ddv8ig8ZSDb8KCWrHoQYFEKZF53vQts3FqlG/HoV+veyefyAISZ0oCteDWV 4OFJMANdnHrRbkZ1EVLsqYOMLWTrKn2hLa/p8LS0LyUpMTWrzn4wpDxJwzKx8bumjRPC XGM+Yg6FWQj/dts2VCGCzd76Umc6NGVdfh+nKK3uc2YI7618cOgGH93GnUNzP1N2NuTa WQmg== X-Gm-Message-State: AHQUAubYHyCz7xQ0tsDzXSRdBoc7odMcK7tEbsRjsGHFExjTgAQmpNyR aFhhNpWDfnSojaheAQIhew== X-Google-Smtp-Source: AHgI3IYmvcjYI7/QKtyfDdi0eUZzzYtS3tTDlcEK8OY4ACtPsTIjNIB2G7w9jpoSFkXFA/4MbZEgDg== X-Received: by 2002:aca:da43:: with SMTP id r64mr633505oig.119.1551377847861; Thu, 28 Feb 2019 10:17:27 -0800 (PST) Received: from serve.minyard.net (serve.minyard.net. [2001:470:b8f6:1b::1]) by smtp.gmail.com with ESMTPSA id k25sm2751743otl.58.2019.02.28.10.17.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Feb 2019 10:17:25 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id E1ED0180903; Thu, 28 Feb 2019 18:17:14 +0000 (UTC) Received: by t430.minyard.net (Postfix, from userid 1000) id D081B3028CF; Thu, 28 Feb 2019 12:17:14 -0600 (CST) From: minyard@acm.org To: Peter Maydell Date: Thu, 28 Feb 2019 12:17:10 -0600 Message-Id: <20190228181710.2477-20-minyard@acm.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190228181710.2477-1-minyard@acm.org> References: <20190228181710.2477-1-minyard@acm.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::231 Subject: [Qemu-devel] [PULL 19/19] i2c: Verify that the count passed in to smbus_eeprom_init() is valid X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard , QEMU Developers , minyard@acm.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Corey Minyard Keep someone from passing in a bogus number Signed-off-by: Corey Minyard --- hw/i2c/smbus_eeprom.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c index 0ba5763fc2..37167e7244 100644 --- a/hw/i2c/smbus_eeprom.c +++ b/hw/i2c/smbus_eeprom.c @@ -180,6 +180,8 @@ void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom, { int i; /* XXX: make this persistent */ + + assert(nb_eeprom <= 8); uint8_t *eeprom_buf = g_malloc0(8 * SMBUS_EEPROM_SIZE); if (eeprom_spd_size > 0) { memcpy(eeprom_buf, eeprom_spd, eeprom_spd_size);